Cron job

Posted by peter on October 24, 2011

Jobs of individual users

These are stored in a the /var/spool/cron/tabs/ folder. These can be edited with the crontab command

crontab -e Creates or edits a cron job

crontab file Specifies a file containing a list of jobs

crontab -l Displays current jobs

crontab -r Deletes all jobs
Scheduling

Write a script and save to a directory

Now use the following command:

crontab [-u user] [-] [-e | -r] [file to run]

Or log on as that user and do the following:

1. Type “crontab -e” at the command prompt

2. Edit the file as needed (it uses “vi”)

You will need at least 6 fields for a simple cron job.

——————————————————————————————————————

Minutes Hours Day of the month Month Weekday Command

30             13       *                         *            1          command

——————————————————————————————————————-

Examples:

To get a job to run at 13:30 every Monday type the following

30  13  *  *  1  /root/command.sh

To get the command to run every 1st of the month type the following:

30  13  1-12   * /root/command.sh

To get a job to run every 10 minutes from 8 to 5, 5 days a week, type the following:

*/10   8-17  *  *  1-5  /root/conmmand.sh

You can also set a script or command to run when the computer boots up

@bootup /scripts/firewall.sh

Comments:

Leave a Reply



(Your email will not be publicly displayed.)

Please type the letters and numbers shown in the image.Captcha CodeClick the image to see another captcha.