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.

  • 1
    whose crontab is the job running as? Sep 27, 2010 at 19:17
  • 3
    and out of curiosity, why are you restarting the syslog ever couple of hours? Usually it's one of those "fire and forget" processes. Sep 27, 2010 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, 2010 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.
    – timetofly
    Sep 27, 2010 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) Jan 19, 2011 at 22:29

1 Answer 1


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.

  • 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?
    – timetofly
    Sep 27, 2010 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, 2010 at 19:25
  • Yes, I'm the owner. How do I find out who the owner is of cPanel's cron?
    – timetofly
    Sep 27, 2010 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, 2010 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?
    – timetofly
    Sep 27, 2010 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .