1

Coming from Why is my crontab not working, and how can I troubleshoot it? i still don`t know why my command is not executed.

I got same command for root and www-data

enter image description here

and my cron logs shows that cron is executed every minute

enter image description here

however, i never got /tmp/crontest.log file. I notice this problem because i wanted to make wordpress external cron (executing php file).

Of course, executing that command from command line is working.

Any tips?

2 Answers2

4

Your crontab file has the wrong lineendings - it's got carriage return (CR)/linefeed (LF) endings. You can see this in your first screenshot, where there's a [dos] after the filename. Unix systems expect lines to be terminated by linefeeds only, whereas Windows systems use a carriage return/linefeed pair.

There are a few ways to correct this. As you seem to be familiar with vi, I'd suggest this to replace the CR/LFs with LFs. Just edit your crontab and then do the search and replace.

mjturner
  • 502
  • 3
  • 9
1
  1. The dos2unix command can convert DOS CR/LF characters in your files to proper LFs. Probably easier than messing around in an editor.
  2. Depending on your editor, it may not leave a trailing LF at the last line either. Some cron implementations still fail to run the last command in a crontab file unless terminated with an LF character at the end.
Magellan
  • 4,471