Results 1 to 9 of 9
CRON JOB COMPLETETION
1) How to know whether cronjob has been completed as scheduled.
2) Cronjob often tries to send message to my mail id but i would like to ...
- 08-04-2011 #1Just Joined!
- Join Date
- Jul 2011
- Location
- Chennai, Tamilnadu
- Posts
- 13
Cron job completetion
CRON JOB COMPLETETION

1) How to know whether cronjob has been completed as scheduled.
2) Cronjob often tries to send message to my mail id but i would like to find the output in the terminal window ,similar kind of "WALL".
3) even i tried to output the file to tmp file but i didn't find the file is executing.
Here is my code
#!/bin/bash
MAILTO="xxx"
01 **** /home/demo1.sh /tmp/cronjob.log
I don't want the o/p to be sent to my email id rather i would like to show up the output either in a X window as popup or in the terminal window.
Your valuable assistance and feedback is highly appreciated.
- 08-04-2011 #2Just Joined!
- Join Date
- Jul 2011
- Location
- Chennai, Tamilnadu
- Posts
- 13
Please give me with step by step instruction to create a cronjob and find the o/p of it. I am new to linux
- 08-04-2011 #3Just Joined!
- Join Date
- Jun 2011
- Posts
- 30
Start cron with the option -s in your daemon (/etc/init.d/crond or /lib/systemd/system/crond.service) and restart the cron daemon.
This will direct all outputs to the syslog.
If you want it for one or more jobs (but not all) there is a workaround:
start your scheduled job in a script and redirect all outputs (also the errors)
Example:
#!/bin/sh
myCronJob > /tmp/myCronJob.log 2> /tmp/myCronJob.err
- 08-04-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Where did you save that code you've posted? If it is a cronjob, you do not need the #!/bin/bash at the top.
To create a cronjob, run:
Now insert the appropriate stuff for the cronjob, e.g.:Code:crontab -e
Then save and quit the file. Note that /home/demo1.sh must be executable.Code:MAILTO="xxx" 1 * * * * /home/demo1.sh /tmp/cronjob.log 2>&1
To list your installed cronjobs:
If the cron daemon is already running, you don't need to restart it - the new job will get picked up.Code:crontab -l
Look in the cron log (usually /var/log/cron) for errors, etc. Your log file (/tmp/cronjob.log) should contain the output (STDERR/STDOUT) of your script.
- 08-07-2011 #5Just Joined!
- Join Date
- Jul 2011
- Location
- Chennai, Tamilnadu
- Posts
- 13
Hi atreya and Kdg, Thank you so much for your valuable making me understanding this topic, I got the output as u said, but when I changed the output in demo1.sh file and look under the folder /tmp/cronjob.log i am finding the old output as i find before could you please tell me
- 08-07-2011 #6Just Joined!
- Join Date
- Jun 2011
- Posts
- 30
Do you have the logs in /var/log/cron?
You're sure the sheduled job has run?
Do you have output(s) when you run demo1.sh directly from a shell process?
Can you post demo1.sh?
- 08-08-2011 #7Just Joined!
- Join Date
- Jul 2011
- Location
- Chennai, Tamilnadu
- Posts
- 13
here is the demo1.sh file
Clear
echo "this is testing"
echo "See the todays date"
date -u
When i compile the demo file i am able to get the output but when i put it in cron job i am getting only the first echo window as o/p "This is testing" in /tmp/cronjob
- 08-08-2011 #8Just Joined!
- Join Date
- Jun 2011
- Posts
- 30
I can simulate your error.
Here's my code for demo1.sh
You should have a simular line in /etc/crontab (just an example, it will run every 3 minutes):Code:$> cat demo1.sh #!/bin/bash clear echo "this is testing" echo "See the todays date" date -u
0-59/3 * * * * root run-parts /etc/cron.test4Forum.
If your troubles persists, can you also post the configuration files:
- /etc/crontab
- /etc/init.d. or /lib/systemd/system/crond.service
Don't forget to restart the cron-daemon each time you change one of the these files.
Code:$> service crond restart
- 08-08-2011 #9Just Joined!
- Join Date
- Jun 2011
- Posts
- 30
Do you have a line in /etc/rsyslog.conf like this:
cron.* /var/log/cron?This line means that all cron logs are written in the file /var/log/cron.
.
BTW: if you change this file, you should restart the rsyslog-daemon:
Code:$> service rsyslog restart


Reply With Quote
