Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I wanted to clean the cron log in /var/log so I delete it with rm cron.

Then I created a new file with cat > cron, but no logs are being stored in that file.

I don't know how to see cron logs again.

The server is with CentOS and the file has permissions:

-rw-r--r--   1 root root      0 sep  6 09:42 cron
share|improve this question

2 Answers 2

up vote 4 down vote accepted

It is likely that your original /var/log/cron file is open for writing by a daemon which is most likely syslogd or rsyslogd. The file will still be open and will still be in use.

Find the PID of your syslogd | rsyslogd then use

sudo kill -HUP <PID>

this should cause the file to be flushed and closed and a new one opened.

share|improve this answer
    
Thanks. I'm using top to list processes but I can't find it. I don't know how to show all the list that is truncated at the window height. I'm connecting through SSH Secure Shell. –  Memochipan Sep 6 '11 at 16:01
1  
@Memochipan: ps -ef | grep syslog –  Iain Sep 6 '11 at 16:02
    
Thanks I obtained: root 1291 1 0 Aug31 ? 00:00:00 /sbin/rsyslogd -c 4 gdm 1917 1 0 Aug31 ? 00:00:00 /usr/bin/pulseaudio --start --log-target=syslog root 18133 17431 0 11:11 pts/0 00:00:00 grep syslog------------------------Then I wrote sudo kill -HUP 1291 and it worked! Again I see the logs! Thank you very much! –  Memochipan Sep 6 '11 at 16:14

And the root:root ownership may be the problem. It has to be owned by the user/group running cron. Look at another CentOS machine and set the ownership with chown user:group /var/log/cron.

Maybe you have files named cron.0, cron.1 in /var/log and you can copy the ownership from them.

share|improve this answer
    
Thanks this is what I have in the other cron files of the same Machine: -rw-r--r-- 1 root root 0 sep 6 09:42 cron -rw------- 1 root root 175071 ago 14 03:35 cron-20110814 -rw------- 1 root root 174786 ago 21 03:19 cron-20110821 -rw------- 1 root root 176033 ago 28 03:44 cron-20110828 -rw------- 1 root root 175302 sep 4 03:38 cron-20110904 –  Memochipan Sep 6 '11 at 15:32
    
In other CentOs this is what I have: -rw------- 1 root root 56609 sep 6 10:30 cron -rw------- 1 root root 167611 ago 14 03:08 cron-20110814 -rw------- 1 root root 169034 ago 21 03:24 cron-20110821 -rw------- 1 root root 168223 ago 28 03:33 cron-20110828 -rw------- 1 root root 169105 sep 4 03:14 cron-20110904 –  Memochipan Sep 6 '11 at 15:34
    
So then @Iain is right. Restarting of the log deamon (or in worst case the server) will do the trick. –  mailq Sep 6 '11 at 15:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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