Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a file called ntpdate in /etc/cron.hourly

date > /tmp/william_tmp
date > /william_tmp
date > ~/william_tmp
echo test

I also did Chmod 755 to this file.

However, I can't tell if the file has run or not!

The file is not created in any of the 3 directories.

If I manually run cd / && run-parts --report /etc/cron.hourly then the files are created and I get the echo.

Can anyone recommend (ideally step by step!) instructions to test that it is working?

share|improve this question
up vote 16 down vote accepted

One major pitfall to cron is cron runs in an extremely limited shell environment, as a result a lot of variables aren't exported in to the environment, mainly $PATH. Make sure you use all absolute paths to executable, including common functions like echo, uptime, date, etc all need to use full paths (/bin/echo, /bin/date, /usr/bin/uptime). To determine the path to an executable, you can use the which command like so: which echo - this will show you the full path to that tool.

share|improve this answer
As discussed in chat, thanks for this and I really hope it will help someone else... Whilst I did the fall path to ntpdate, I am so used to Windows and echo/date being just "built in", I just didn't think I would need full path... learning a lot more about Linux and it makes perfect sense! – wilhil Jun 11 '12 at 23:56

You should look in your /var/log/syslog log file. If a cron has run, it would have a line like:

Jun 11 19:09:01 penguin CRON[17376]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)
Jun 11 19:17:01 penguin CRON[17799]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

For troubleshooting tips, see

share|improve this answer
There isn't anything in Syslog and I can't see any reason why it would fail from that link :( – wilhil Jun 11 '12 at 22:15
If there are no entries in syslog (grep -i cron /var/log/syslog /var/log/syslog.1), start checking whether the cron daemon is running: ps uww -C cron should contain a line with a process. – Lekensteyn Jun 11 '12 at 22:20
Sorry for being misleading, there are entires for Cron in the syslog, just nothing relating to this command... I know some jobs get run as every hour, I get a new mail alert... AFAIK, the ones that are working are from crontab, there is nothing in cron.hourly which is what I am trying to get working – wilhil Jun 11 '12 at 22:25

Try changing the first line of your script (the interpreter) to:


I've also had problems in the past, with environment variables and PATH issues. After changing the interpreter to bash my issues were gone.

share|improve this answer

Given I've added the script in /etc/cron.hourly/

Just filter CRON tasks in terminal with the powerful egrep and awk:

$ cat /var/log/syslog | egrep clearme | awk "{ print $1 }" > ~/Desktop/cronlog.txt

The output will look like:

Jan 14 15:20:01 markets-dev CRON[10089]: (dminca) CMD (root /etc/cron.hourly/
Jan 14 15:40:01 markets-dev CRON[18042]: (dminca) CMD (root /etc/cron.hourly/
Jan 14 16:00:01 markets-dev CRON[22817]: (dminca) CMD (root /etc/cron.hourly/
Jan 14 16:20:01 markets-dev CRON[28183]: (dminca) CMD (root /etc/cron.hourly/
Jan 14 16:40:01 markets-dev CRON[411]: (dminca) CMD (root /etc/cron.hourly/
Jan 14 17:00:01 markets-dev CRON[5442]: (dminca) CMD (root /etc/cron.hourly/
Jan 14 17:20:01 markets-dev CRON[11935]: (dminca) CMD (root /etc/cron.hourly/

To explain everything step-by-step:

  1. cat /var/log/syslog - print me the System log
  2. egrep clearme - but only select rows that contain the text clearme
  3. awk "{ print $1 }" - print me that row that contains the text clearme
  4. > ~/Desktop/cronlog.txt - output the results in the file cronlog.txt located on the Desktop directory.

The 4th step is optional. It will just print results in the terminal instead of the file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.