Updated on: 3.Jun.2014
To view the scheduled jobs, run this command:
sudo crontab -l
For example, I want to copy user directory to another directory daily:
cd /etc/cron.daily
Then, create a "backup" bash file:
sudo nano backup
In the "backup" bash file, it looks like this:
#!/bin/sh
rsync -az /home /mnt/backup2
Once you are done, press CTRL+X. Press Y to confirm saving.
The final step is to give permission for the bash file to execute
sudo chmod 777 backup
To test the script manually,
. backup
The following directories contain the scheduled jobs (which runs as root):
- /etc/cron.daily
- /etc/cron.hourly
- /etc/cron.monthly
- /etc/cron.weekly
- /var/spool/cron => this directory contains the scheduled jobs for each users.
To create a schedule job that runs at specific time, run the following command,
sudo crontab -e
Then, add a line with "schedule" and "command/script file" (you will find the details in the crontab file itself). For example, print current date time every 5 minutes.
*/5 * * * * date
To check if the scheduled job is running
sudo tail /var/log/syslog
http://unix.stackexchange.com/questions/7053/how-can-get-a-list-of-all-scheduled-cron-jobs-on-my-machine
https://help.ubuntu.com/community/CronHowto
No comments:
Post a Comment