Setting up a Cron job

Crontab is a useful program that allows you to execute a command when ever you want it to run. Crontab can be found on most, if not all, Linux and Unix systems.

Getting Started with Crontab…
Type crontab -e as the user that you want the Cron Job to be executed as.
The format of the job is like this.

I’m going to use some varibles, you should remember those from algebra, for those of you that don’t it is a letter that represents another value (usually a number).

a b c d e f

where…
a = The minute after the hour that you want it done
b = The hour you want it done (Military Time)
c = Day of the Month
d = Month of the Year
e = Day of the week
f = ‘command’

5 0 * * * /usr/local/bin/email
Like the above example, /usr/local/bin/email, will run every night at 12:05 AM.
The * means to run every instance of the value in the field. Like a asterisk in the day field means to run everyday

Other Useful crontab commands
crontab -e opens the editor
crontab -l lists the contents of the crontab
crontab -r removes the crontab

Advertisements

About synapse
Programming, motorcycles and photography. Want to do more, but only have time for so much!

3 Responses to Setting up a Cron job

  1. Pingback: history meningitis

  2. Pingback: maui built clothing

  3. Pingback: bath body

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: