Skip to content

Instantly share code, notes, and snippets.

@tamboer
Last active December 22, 2015 02:48
Show Gist options
  • Select an option

  • Save tamboer/6405388 to your computer and use it in GitHub Desktop.

Select an option

Save tamboer/6405388 to your computer and use it in GitHub Desktop.
cron jobs general
=======================
tail -f /var/log/syslog
=======================
#min hour day month weekday command
*/1 * * * * <your command>
#weekdays at 9am
0 9 * * 1-5 /home/user/hello_script.sh
crontab -e
*/1 * * * * echo "job every minute"
==================================================================
*/1 * * * * /usr/bin/wget -O /dev/null http://example.com/cron.php
Any difference between * and */1?
CLI mode vs. calling http URLS
=================================================================
1 * * * * /path/to/command
=================================================================
You could tell wget to not download the contents in a couple of different ways:
wget --spider http://www.example.com/cronit.php
which will just perform a HEAD request but probably do what you want
wget -O /dev/null http://www.example.com/cronit.php
which will save the output to /dev/null (a black hole)
You might want to look at wget's -q switch too which prevents it from creating output
I think that the best option would probably be:
wget -q --spider http://www.example.com/cronit.php
that's unless you have some special logic checking the HTTP method used to request the page
Matt Cutts: Gadgets, Google, and SEO
How to fetch a url with curl or wget silently
Posted January 3, 2007 in How to, Linux/Ubuntu, Productivity
Cron jobs need quiet operation; if a command generates output, you’ll get an email from cron with the command output. So if you want to fetch a file silently with wget or curl, use a command like this:
curl –silent –output output_filename http://example.com/urltofetch.html
wget –quiet –output-document output_filename http://example.com/urltofetch.html
There are shorter versions of these options, but using the verbose options will make code or cron jobs easier to understand if you come back to them. Be aware that urls with “&” in them can confuse wget at least, so depending on your shell (bash, csh, tcsh), you may need to put single or double quotes around the url.
This would trigger the cron only when it's 1 minute after an hour. I.e. 1:01, 2:01 etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment