0

I have a script that occasionally needs to run the command "service udev reload" but cannot as it needs root access. I don't want to stay logged in as root all the time, so I'm wondering if there is a way to change permissions for this command.

I'm on 12.04.

Any ideas?

1 Answers1

0

From the man page: sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.

So, this is the proper way to restart a service:

sudo service udev reload

if you do not want to do it by hand, you can always add an entry in crontab to execute the command at time intervals

girardengo
  • 4,965
  • 1
  • 26
  • 31
  • Just to check, this would have to be in the /etc/cron.hourly or /etc/cron.daily (or related variants) folders, right? – saiarcot895 Apr 24 '14 at 23:32
  • yes, adding a script in those directories, or edit crontab with sudo crontab -e and add a line with command/script putting the date and time you want. Refer to man crontab for more help. – girardengo Apr 24 '14 at 23:48
  • I don't really know the answer to OP's question, but I think this is missing the point. I think he already has a script that runs sudo service udev reload, but he wants to be able to run that specific command without sudo and still have it work. – jarvisschultz Apr 25 '14 at 21:05