Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Crontab with Ubuntu

Similar presentations


Presentation on theme: "Using Crontab with Ubuntu"— Presentation transcript:

1 Using Crontab with Ubuntu
(scheduling jobs that repeat) Presented by Dave Mawdsley, DACS Member, Linux SIG December 16, 2009

2 What are Crontab and Cron?
1 crontab is a command line utility to manage cron jobs. The utility has 3 main options: crontab -l (list the cron jobs) crontab -e (edit the cron jobs using the default editor such as Nano) crontab -r (remove all cron jobs) cron is a daemon running in the background which checks every minute the computer is on to see if a job is scheduled to be performed. If a job is found, it then performs the required actions.

3 2 How Could Cron be Used? On a customized periodic schedule cron could be used to... make automated backups. rotate system logs or to report a network status. update software on various pieces of connected hardware. send a reminder to a desktop or via .

4 Crontab Fields 3

5 Sample Time/Date/Day Fields
4

6 Cron Jobs on My Laptop 5

7 My Dell Mini-9 Desktop 6

8 A Sample Script 7

9 8 A Cron Job

10 The Text File Output 9 12:55:01 PM This script totals two numbers.
45 plus 86 is 131

11 Cron & Rsync Issues 10 Consider the following crontab task for Friday at 5:30 PM: 30 17 * * 5 rsync -r -t -p -o -v --progress -l -e “ssh” :/home/madmod/Documents/ /home/madmod/MadMod-Desktop-Backup/Documents/ ; /bin/date >> Desktop/bakuplog ; /bin/echo “ Doc's backup done.” >> Desktop/bakuplog To work, the public key id_rsa.pub of the source computer must be stored in the destination computer's .ssh folder to prevent a password prompt when the cron job occurs. Further, I suggest that id_rsa.pub should first be stored as key.txt in the destination computer's <user home folder>/.ssh --and then it must be added to the executable authenticated_keys text file in that same folder. While in that .ssh folder, I suggest the following append: $ cat key.txt >> authenticated_keys (Note: if the file authenticated_keys isn't present, the file will be made.)

12 Concluding Remarks 11 When using crontab -e my computer uses Nano. With Nano... Cron jobs must be on one line each with no carriage return, line feed. If the line wraps, be sure to delete a character just in front of the second line so cron thinks it's all on one line. Use Ctrl+x followed by y and then Enter to save the list of cron jobs. Crontab wants commented lines with # only at the top of the list. Be sure that path and environment variables are okay. Be careful to make the minutes slightly different between cron jobs so that two jobs don't try to run simultaneously. This might cause problems. The computer or server must be on for cron to work. It doesn't catch up later on missed jobs. (Anacron may be useful here.) Use crontab -l to make sure that your listing is correct.

13 Using Crontab with Ubuntu
12 Using Crontab with Ubuntu (scheduling jobs that repeat) This OpenOffice.org Presentation 'cronubun.odp' can be downloaded from


Download ppt "Using Crontab with Ubuntu"

Similar presentations


Ads by Google