Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get a couple of programs to restart via cron every x hours (like for example syslog-ng using "/etc/init.d/syslog-ng restart"). However, the following always gets returned:

Stopping syslog-ng: [FAILED]
rm: cannot remove `/var/lock/subsys/syslog-ng': Permission denied
Starting syslog-ng: Error opening file for reading; filename='/proc/kmsg', error='Permission denied (13)'
Error initializing source driver; source='s_sys'

Which file permissions do I need to change in order to be able to restart the programs with cron?

Thanks a lot.

share|improve this question
whose crontab is the job running as? – Bart Silverstrim Sep 27 '10 at 19:17
and out of curiosity, why are you restarting the syslog ever couple of hours? Usually it's one of those "fire and forget" processes. – Bart Silverstrim Sep 27 '10 at 19:18
Expanding on Bart's line of thought...what exactly are you trying to accomplish here? It's very likely there's a much easier method than trying to restart a service regularly. – EEAA Sep 27 '10 at 19:27
Bart: It's running as a cpanel user, which ErikA says is the same user as the specific cpanel username. Syslog-ng is only one of the programs I want to restart, but the reason I want it is that I found that a specific program of mine doesn't write to a log file after it has been rotated by logrotate. The new log file that logrotate creates remains empty, and only a restart of syslog makes it write to the necessary file. – Blossoming_Flower Sep 27 '10 at 20:12
that's a problem of logrotate. you could either use kill -9 HUP pidof syslogd in logroate postscript or use truncate (a very delayed answer :p) – Nikolaidis Fotis Jan 19 '11 at 22:29
up vote 0 down vote accepted

Which user's crontab are you running this from? If it is root's crontab, no additional permissions should be needed. If running it from a non-privileged user's crontab, then you'll need to grant that user permission to run the desired command using sudo.

share|improve this answer
Hey, I'm using cron through cPanel. Do you know what user that is? Could you please provide me a link to instructions to do this? Which file do I change the permissions for? – Blossoming_Flower Sep 27 '10 at 19:22
Are you the owner of this server? If so, then you'll still need to go in via ssh and, using the visudo command, grant your user permissions to run the command using escalated privileges. There are guides aplenty available if you just do a google search for "sudo howto". If you're not the owner of the server, then you're out of luck, as there's no way a hosting company is going to let you arbitrarily restart services on their machine. – EEAA Sep 27 '10 at 19:25
Yes, I'm the owner. How do I find out who the owner is of cPanel's cron? – Blossoming_Flower Sep 27 '10 at 19:37
In all the cPanel setups I've used, the system user is the same as the user you use to sign into cPanel. The question remains, though...what exactly are you trying to accomplish. It's highly unlikely that restarting syslog regularly is an appropriate solution to whatever you're trying to accomplish. – EEAA Sep 27 '10 at 19:41
Thanks for the reply. Syslog-ng is just one of them--I have some personalized software that also needs regular restarts. One more question: wouldn't it just be easier to download the sudo file using WinSCP and editing it using a text editing program rather than through visudo? – Blossoming_Flower Sep 27 '10 at 20:04

Your Answer


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.