LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 09-19-2004, 10:31 AM   #1
haldara
LQ Newbie
 
Registered: Jul 2003
Posts: 19

Rep: Reputation: 0
cron problem


Hi guys:


So I decided to add an entry to my crontab for root that would automatically delete the cron log in /var/log/cron every month and just add a timestamp to let me know that it had been done. However, even with the correct perms, for some reason, the log file is no longer being written to. Here is my crontab entry for root:

52 4 19 1-12 * rm -rf /var/log/cron ; touch /var/log/cron; echo "Refreshed Cronlog: " > /var/log/cron; date >> /var/log/cron;

Here are the permissions:
-rw-rw-rw- 1 root root .... /var/log/cron

Any thoughts?
- ADH
 
Old 09-19-2004, 10:46 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

You are deleting an 'open file'.

/var/log/cron is an open file, which means that your logdaemon (probably syslogd) keeps this file open to write output too.

When you delete the file and create it again, the 'pipe' from syslogd to /var/log/cron points to the deleted /var/log/cron and not to the newly created /var/log/cron (there's a bit more going on, but I'm keeping it simple).

So, instead of using:
rm -rf /var/log/cron ; touch /var/log/cron
use:
> /var/log/cron

This will empty /var/log/cron without breaking the pipe.

Hope this clears things up a bit.
 
Old 09-19-2004, 11:00 AM   #3
haldara
LQ Newbie
 
Registered: Jul 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Awesome, that makes alot of sense.

Since I already broke the pipe, is there anyway to recreate the pipe from syslogd to this new /var/log/crond without rebooting?

Thanks!
 
Old 09-19-2004, 11:42 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
You need to restart syslogd.

You do not tell what distro you are using, the file could be in /etc/rc.d/init.d or in /etc/init.d and the name should reflect syslog.

To actually restart do something like this (example is from my machine):

$ /etc/rc.d/init.d/sysklogd restart

Another, maybe easier way is to look for the syslog process in the process list (ps -ef | grep syslog) and give a SIGHUP signal to the pid belonging to syslog.

$ ps -ef | grep [s]yslog
$ kill -SIGHUP <pid>


Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
Cron Problem !!! lionking_x Linux - Newbie 6 12-13-2004 04:36 PM
cron problem... wrongman Linux - Software 3 06-06-2004 01:21 PM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 09:57 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM


All times are GMT -5. The time now is 10:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration