|
Linux allows you to schedule a command to run at a specified time. You can use this ability to schedule scripts to run automatically. You schedule jobs using the crontab command. The first time you schedule a job, you create a file with the commands you want to schedule. Each command goes on a separate line. The crontab format requires six items on the line, each separated by a space. The items are, in the order of occurrence:
Each item must be present. If an item is not relevant for your scheduling, enter *. Below are two crontab entries that run a shell script: 59 0 * * * /home/janet/backup 0 2 * * 5 /home/janet/cleanup The first line runs the script backup at midnight every night. The second line runs cleanup at 2 a.m. every Friday. Create a file named crontab that contains entries for the jobs you want to run automatically. To schedule your jobs, type: crontab crontab This will schedule your jobs. If the command fails, you may need to change to the root account. As root, you can schedule the job for another user, as follows: crontab -u janet crontab You can see what is scheduled for you by typing: crontab -l You can change your scheduled jobs by typing: crontab -e |
|