LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   how to run a job as a different user from crontab (http://www.linuxquestions.org/questions/linux-server-73/how-to-run-a-job-as-a-different-user-from-crontab-754797/)

digitallyamar 09-13-2009 07:22 AM

how to run a job as a different user from crontab
 
How do i run a script(say abc.pl) in cronjob with some other user id.

Say, I am admin of a server and i want to run a script abc.pl as user X through cron job at the some particular time of day. How do i do it using cronjob that runs with my id.

Any suggestions?

EricTRA 09-13-2009 07:26 AM

Hello,

You can su - to the user or edit the user's crontab directly if you're root:
Code:

crontab -u <user> -e
You could also edit the user's crontab files. Location depends on what distro you're using.

Kind regards,

Eric

repo 09-13-2009 07:39 AM

or use
Code:

15 * * * * username /usr/bin/somecommand
Make sure the user has access to all commands in the script


All times are GMT -5. The time now is 09:30 PM.