1. Say I have a script named "testcron" containing the following:

    #!/bin/bash echo This script ran on $(date)

  2. I then set the permissions: chmod ug+x testcron

  3. Finally, I copy this script to /etc/cron.hourly
  4. And I wait for something to happen at the next hour.

So, I found in the /var/log/cron the following entry: Jul 17 12:01:02 localhost run-parts(/etc/cron.hourly)[13218]: starting testcron Jul 17 12:01:02 localhost run-parts(/etc/cron.hourly)[13240]: finished testcron

However, I could not find the script's actual output anywhere. Where does the output of this script go? Is it mailed? The root has no mail account. Can I redirect the mail to another user for just this script or will all mail output end up in the user's account? Does it go to /var/log/messages? What is the correct way redirect the output to, say, a dedicated log file?

Note: The script I included above doesn't actually do anything useful but I want to adapt the principles to another script that does.

OS: centos 7

Thanks to all in advance, Allan


On CentOS, it doesn’t seem to be logging output anywhere, just the fact that the cron has executed is stored in /var/log/cron.

If you need the output, you can use standard shell redirection. First create a file:

touch /var/log/cronoutput

Then capture the output of your cron, example:

* * * * * echo "hey" >> /var/log/cronoutput


tail /var/log/cronoutput
  • There is no such file on this system. – AWM Jul 17 at 16:16
  • There is a file named /var/log/cron that contains entries indicating the start and finish of cron jobs but no output from the actual script run. – AWM Jul 17 at 16:17
  • Try /var/log/messages ? – notStan Jul 17 at 16:18
  • That file exists but doen't have the output from the script. – AWM Jul 17 at 16:18
  • Hmm, it doesn’t seem that it logs it. You’d have to create your own file to capture the output. Updating my answer. – notStan Jul 17 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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