Linux - NewbieThis 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.
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.
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:
/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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.