Say I have a script named "testcron" containing the following:
#!/bin/bash echo This script ran on $(date)
I then set the permissions:
chmod ug+x testcron
- Finally, I copy this script to /etc/cron.hourly
- 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): starting testcron
Jul 17 12:01:02 localhost run-parts(/etc/cron.hourly): 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