Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-19-2006, 11:23 AM
|
#1
|
Member
Registered: Jun 2006
Posts: 41
Rep:
|
Cron log
I set up a cron job and want to prove to my professor that it is working. Is there a log file that records that it actually took place?
I'm looking in the /var/log/cron file and it does not seem to have recorded it, although I know it took place.
HK
|
|
|
09-19-2006, 01:23 PM
|
#2
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
/var/log/cronlog should show if the cron job was initiated but it won't give you any details of what that job did. That is to say it is simply a log for cron scheduling not for the jobs themselves.
When creating a job you want to get better logging for you should just add it to the crontab with redirect statements:
1 * * * * myscript.sh >>/somelogdir/myscript.log 2>&1
Where myscript and somelogdir are the names you choose. The above will send any output of myscript.sh to somelogdir/myscript.log and also redirect any errors to that same log. Of course if the script had no output or errors you wouldn't see anything in the log. You can modify the script by doing things like:
date
echo "Now running something"
These statements would display the screen when run from the command line but when run from cron (using the above redirect) would go to the logfile you'd created.
|
|
|
09-20-2006, 08:00 AM
|
#3
|
Member
Registered: Jun 2006
Posts: 41
Original Poster
Rep:
|
It Worked!
Thanks for your help!
|
|
|
09-20-2006, 09:44 AM
|
#4
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515
Rep:
|
Alternatively, if you have a MTA (mail transport agent) like sendmail or postfix running, you can make
cron mail the output and error messages back to either the user that submitted the cron jobs (default) or to
a random mail address (by adding "MAILTO=someone@somewhere" at the top of the crontab settings).
|
|
|
All times are GMT -5. The time now is 07:35 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|