Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 09-13-2009, 06:22 AM   #1
LQ Newbie
Registered: Jul 2005
Distribution: RedHat
Posts: 3

Rep: Reputation: 0
how to run a job as a different user from crontab

How do i run a script(say in cronjob with some other user id.

Say, I am admin of a server and i want to run a script 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?
Old 09-13-2009, 06:26 AM   #2
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295

You can su - to the user or edit the user's crontab directly if you're root:
crontab -u <user> -e
You could also edit the user's crontab files. Location depends on what distro you're using.

Kind regards,


Last edited by EricTRA; 09-13-2009 at 06:38 AM.
Old 09-13-2009, 06:39 AM   #3
LQ 5k Club
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
or use
15 * * * * username /usr/bin/somecommand
Make sure the user has access to all commands in the script

Last edited by repo; 09-13-2009 at 06:42 AM.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run crontab job for every 5 seconds vamsi_k Linux - Newbie 2 09-03-2008 02:08 PM
how to run crontab job for every 5 seconds vamsi_k Linux - Newbie 1 09-03-2008 11:31 AM
the crontab job is not run ust Linux - Software 1 03-24-2008 07:03 PM
Run crontab job sunhui Linux - Software 2 05-16-2007 08:35 PM
crontab job and run on shell sunhui Linux - Software 1 02-13-2007 05:35 AM

All times are GMT -5. The time now is 04:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration