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

Notices

Reply
 
Search this Thread
Old 09-13-2009, 06:22 AM   #1
digitallyamar
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 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?
 
Old 09-13-2009, 06:26 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
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

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

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
or use
Code:
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.
 
  


Reply

Tags
cronjob


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 05:24 PM.

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