Mainos / Advertisement:
Crontab
Versio hetkellä 12. elokuuta 2015 kello 10.00 – tehnyt Frans (keskustelu | muokkaukset) (Ak: Uusi sivu: http://forum.ubuntu-fi.org/index.php?topic=8541 (Finnish))
Crontab is a useful tool to schedule tasks in Linux.
Sisällysluettelo
Scheduling
Scheduling tasks with crontab is pretty simple:
* * * * * command to be run ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ └───── weekday (0 - 7) (0 or 7 = sunday) │ │ │ └────────── month (1 - 12) │ │ └─────────────── day (1 - 31) │ └──────────────────── hour (0 - 23) └───────────────────────── minute (0 - 59)
The crontab configuration file is
/etc/crontab
Scheduling examples
Print something every minute
*/1 * * * * echo "This prints every minute."
Print something every hour
0 1 * * * * root echo"This prints something every hour."
Run a sh script every hour
0 1 * * * * root sh /root/backup.sh
Update dynamic DNS every Friday and Monday at 3:45
45 3 * * 1,5 root curl -D - --user useraccount:password http://www.dy.fi/nic/update?hostname=hostname.dy.fi
Disable e-mail notifications
Add the following line to the /etc/crontab file
MAILTO=""
Related info
Sources
Mainos / Advertisement: