Crontab for pkexec as root
Hello everyone,
I am trying to schedule a script through cron. This script utilizes pkexec for running a command. I as a user am able to run the command with pkexec for root. But when I schedule it through crontab then I keep getting the error Error executing command as another user: Not authorized. Please help. |
Haven't used pkexec but after looking at it I'm not sure you need it.
We often run commands as other users from root's crontab by doing something like: Code:
00 * * * * su - myuser -c "/path/to/myscript.pl" >> /var/log/myscript.prod 2>&1 |
Thank you for the response.
The issue am facing is that when am trying to run my script without cron, in this manner su - abhishek -c "/path/to/script" then its asking me password. Does that mean it shall keep popping some GUI for the password every time it tries to run the script. That's not what I need. I wanted it to run in background!!! |
As MensaWater pointed out, you use that technique from the root's(!) crontab; root doesn't require a passwd to login & run a cmd as another user.
You can try it by using 'su -' to get root and then run the cmd manually. (If you're on ubuntu, I believe it's 'sudo su -') |
All times are GMT -5. The time now is 04:24 PM. |