Mainos / Advertisement:
Ero sivun ”Crontab/en” versioiden välillä
Siirry navigaatioon
Siirry hakuun
(Ak: Uusi sivu: Print something every hour) |
(Ak: Uusi sivu: http://forum.ubuntu-fi.org/index.php?topic=8541 (Finnish)) |
||
(9 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
Rivi 29: | Rivi 29: | ||
Print something every hour | Print something every hour | ||
− | 0 1 * * * * root echo" | + | 0 1 * * * * root echo"This prints something every hour." |
− | + | Run a sh script every hour | |
0 1 * * * * root sh /root/backup.sh | 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 | 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="" | MAILTO="" | ||
− | == | + | == Related info == |
[[Backup]] | [[Backup]] | ||
Rivi 51: | Rivi 51: | ||
[[Dynaaminen dns päivitys dy.fi]] | [[Dynaaminen dns päivitys dy.fi]] | ||
− | == | + | == Sources == |
− | http://linux.fi/wiki/Komentojen_ajastaminen | + | http://linux.fi/wiki/Komentojen_ajastaminen (Finnish) |
− | http://forum.ubuntu-fi.org/index.php?topic=8541 | + | http://forum.ubuntu-fi.org/index.php?topic=8541 (Finnish) |
Nykyinen versio 12. elokuuta 2015 kello 10.00
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: