Joyent

Translations of this page:

Creating Cron jobs

Cron jobs are perfect for repetitive tasks that need to be run on every hour, day, week, or month.

From the Shell

Cron jobs are stored in a file, known as crontab (short for cron table). The syntax is as follows:

* * * * * command to be executed
min, hour, day of month, month, day of week, command to be executed

To create a new crontab, or edit the existing crontab for the user currently logged in:

crontab -e 

If you add tasks to this crontab, then the process will be owned by the user which is currently logged in.

If you are EDITOR environment variable is not set, then you your crontab will be loaded in the vi text-editor. If you prefer to use another text editor, such as nano, add the following to your .bashrc file:

export EDITOR=nano

To display your crontab:

crontab -l 

To remove all cron jobs (remove the entire crontab):

crontab -r

From Virtualmin

To set up a Crob job on your account, do the following:

  1. Sign in to Virtualmin (see Account logins and important URLs).
  2. Click Webmin in the upper-left hand corner, the System, then Scheduled Cron Jobs.
  3. Click Create a new scheduled cron job.
  4. Enter the full command to run (including command arguments) into the Command field. Don’t forget to specify full paths to all binaries (e.g. /usr/local/bin/php instead of just php).
  5. Enter a textual description into Description. This is optional but will help you identify cron jobs later on.
  6. Select an execution schedule. The default setting will create a cron job that executes every hour. The options that you select from the list fields will set a time when the job will execute (unless you have the All option select which ignores the particular select list).
  7. When you are done, click Create.
 
accelerators/kb/cron-jobs.txt · Last modified: 2008/01/27 00:58 by alexbcoles
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki