I wish to fetch content from a PHP script on my server two times a day, altering a query variable lang to set what language we want, and save this content in two language specific files. This is my crontab:

*/15 * * * * ~root/apache.sh > /var/log/checkapache.log
10 0 * * * wget -O /path/to/file-sv.sql "http://mydomain.com/path/?lang=sv"
11 0 * * * wget -O /path/to/file-en.sql "http://mydomain.com/path/?lang=en"

The problem is that only the first wget command line is being executed (or to be precise: the only file that is being written is /path/to/file-sv.sql). If I switch the second and the third row, /path/to/file-en.sql gets written instead. The first line always runs as expected, no matter where it is.

I then tried using lynx -dump "http://mydomain.com/path/?lang=xx" > /path/to/file-xx.sql to no avail; still only the first lynx line executed successfully. Even mixing wget and lynx did not change this!

Getting kinda desperate! Am I missing something? There are thousands of articles on crontab (combined with) wget or lynx, but all seems to cover basic setups and syntax. Does anyone got a clue of what I am doing wrong?


  • Are you sure that whenever you access mydomain.com/path/?lang=en something is returned ? have you tried this from a command line to see what happens (wget -O - mydomain.com/path/?lang=en) ?
    – Torian
    Feb 2, 2011 at 21:17
  • 1
    I would try erasing and recreating the carriage return between 2 and 3. Feb 2, 2011 at 21:24
  • Best practice is to specify the full path to the executables in crontab. Like: "/usr/bin/wget". I don't think this would help in your case, since one of the crons works. Feb 2, 2011 at 21:26
  • What is displayed in cron's log when this happens?
    – beans
    Feb 2, 2011 at 21:26
  • @Torian: Works like a charm. Feb 2, 2011 at 21:31

5 Answers 5


Try adding newline at the end of your crontab.

  • 1
    You're a godsend! That did it! I'd vote you up if I had the reputation. :) Feb 2, 2011 at 22:48
  • 1
    @gelraen But... why?
    – Samuel
    Jun 11, 2017 at 6:07

I just spent some time trying the above answers (adding newlines, deleting newlines, etc.) on a system running cronie. Finally found there is a bug in cronie 1.5.3 that only executes the first cron job for each user. It's fixed in 1.5.4


Hope this saves someone some time...


There's something about the text that's wrong. Edit your crontab in vim then show invisible characters.

:set invlist

You should be able to see and then correct it.

  • Wrong how? How do I edit it in Vim? I tried rewriting the whole file in the case that copy-pasting would cause problems. Feb 2, 2011 at 21:55
  • @afEkenholm: how do you edit it now?
    – bahamat
    Feb 2, 2011 at 22:12
  • 1
    @bahamat: # crontab -e Feb 2, 2011 at 22:13
  • @afEkenholm: do this: EDITOR=vim crontab -e
    – bahamat
    Feb 2, 2011 at 22:14
  • @bahamat: Everything looks just fine. Got a purple $ at the end of each line? Feb 2, 2011 at 22:17

Try add redirect, to debug crontab(or read root mail):

11 0 * * * wget -O /path/to/file-en.sql "http://mydomain.com/path/?lang=en" > /tmp/crontab_ouptput 2> /tmp/crontab_error

Also run 'wget -O /path/to/file-en.sql "http://mydomain.com/path/?lang=en"' from console.

Also use 'crontab -e' for validation new crontab.

Also, try delete not working line and retype it from keyboard.

Backup corntab and run command:

crontab -l | crontab -
  • Adding /tmp/crontab_ouptput 2> /tmp/crontab_error only works for the first line. Running the command from the console works just fine. Rewrote the whole file with my bare hands, but nothing changed. Feb 2, 2011 at 22:01
  • Backup crontab and try: crontab -l | crontab -
    – alvosu
    Feb 2, 2011 at 22:23
  • Thanks for the efforts, @alvosu, but a simple newline did the trick! Feb 2, 2011 at 22:49

I also met with the same problem today. I found that it's caused by my server not using the same timezone I am at.

I fixed it by changing the timezone on the server (CentOS 7) with the command:

timedatectl list-timezones
timedatectl set-timezone <My timezone>
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jun 16, 2022 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .