💾 Archived View for darknesscode.xyz › notes › crontab.gmi captured on 2024-02-05 at 09:42:49. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-05)
-=-=-=-=-=-=-
Some examples to work with contrab
Edit crontab just run
crontab -e
Depends of the Linux distro you have it will show just a blank documents or just a bunch of comments
To show the crontab list run
crontab -l
Remove all crontab jobs (be careful with this command)
crontab -r
Edit the crontab for a specific user. The -u option requires administrator privileges
sudo crontab -u <user> -e
List the crontab for a specific user
sudo crontab -l -u <user>
Remove the crontab for a specific user
sudo crontab -r -u <user>
Some examples of crontab entries, you can run any shell script and scheduling
Run the shell script on January 2 at 5:30 A.M
30 4 2 1 * /home/user/backup.sh
Run the same script as above, at 12:01 A.M., every Monday in January
01 00 * Jan Monday /home/user/backup.sh
Run every hour, on the hour, from 9 A.M. (09:00) through 6 P.M. (18:00), every day
00 09-18 * * * /home/user/script.sh
Same as the above, but run it every twenty minutes
Run every Monday, at 5 A.M. and 5 P.M:
0 9,17 * * Mon /home/user/script.sh
Run at 10:30 P.M., every weekday:
30 22 * * Mon,Tue,Wed,Thu,Fri /usr/local/bin/backup
| field | allowed values | | ----- | ----- | | minute | 0-59 | | hour | 0-23 | | day of month | 1-31 | | month | 1-12 (or names) | | day of week | 0-7 (0 or 7 is Sunday |
----------
----------
© DarknessCode