Cron: Difference between revisions
(Created page with "The Linux way to schedule commands. http://www.adminschoice.com/crontab-quick-reference == Setting up a script to run every five minutes == crontab -e") |
No edit summary |
||
(5 intermediate revisions by one other user not shown) | |||
Line 3: | Line 3: | ||
http://www.adminschoice.com/crontab-quick-reference | http://www.adminschoice.com/crontab-quick-reference | ||
== Setting up a script to run every five minutes == | == Setting up a script to run a script in your home folder every five minutes (and log it) == | ||
crontab -e | crontab -e | ||
and edit it to something like: | |||
*/5 * * * * /home/mmurtaugh/xpub.sh > /home/mmurtaugh/xpub.log | |||
This runs the script <code>xpub.sh</code> every 5 minutes, and writes its outputs to xpub.log. | |||
== Log errors == | |||
You can let your program its STDOUT to a logfile, to see if your cronjob works. | |||
Tip: use "append", with double ">>", to see if it is running: | |||
*/5 * * * * /home/mmurtaugh/xpub.sh >> /home/mmurtaugh/xpub.log | |||
Then, you can add <code>2>&1</code> to the end of your line, to write STDERR to STDOUT as well. So in other words: it catches any errors and writes them to your log file. | |||
*/5 * * * * /home/mmurtaugh/xpub.sh >> /home/mmurtaugh/xpub.log 2>&1 | |||
== Argh how to check my cron timing? == | |||
https://crontab.guru/ |
Latest revision as of 11:57, 19 November 2024
The Linux way to schedule commands.
http://www.adminschoice.com/crontab-quick-reference
Setting up a script to run a script in your home folder every five minutes (and log it)
crontab -e
and edit it to something like:
*/5 * * * * /home/mmurtaugh/xpub.sh > /home/mmurtaugh/xpub.log
This runs the script xpub.sh
every 5 minutes, and writes its outputs to xpub.log.
Log errors
You can let your program its STDOUT to a logfile, to see if your cronjob works.
Tip: use "append", with double ">>", to see if it is running:
*/5 * * * * /home/mmurtaugh/xpub.sh >> /home/mmurtaugh/xpub.log
Then, you can add 2>&1
to the end of your line, to write STDERR to STDOUT as well. So in other words: it catches any errors and writes them to your log file.
*/5 * * * * /home/mmurtaugh/xpub.sh >> /home/mmurtaugh/xpub.log 2>&1