Operating System - HP-UX
1834465 Members
3314 Online
110067 Solutions
New Discussion

At command under another user

 
Travis Harp
Advisor

At command under another user

Is there a way run a script using the at command but execute it under another user?
For example, if I want to execute "at -f /home/user/Myusersscript.sh now" from say rc4.d but want it to run under their account and not root. How would I go about that?
Eagles may soar but weasels don't get sucked into jet engines.
6 REPLIES 6
Pete Randall
Outstanding Contributor

Re: At command under another user

Travis,

As root, run a script like this:

su otheruser
at -f /home/user/Myusersscript.sh now



Pete


Pete
Mark Grant
Honored Contributor

Re: At command under another user

su - user -c "at now etc etc"
Never preceed any demonstration with anything more predictive than "watch this"
Umapathy S
Honored Contributor

Re: At command under another user

You can su to another user before running that command in rc4.d.

su -
at -f /home/user/Myusersscript.sh now

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
T G Manikandan
Honored Contributor

Re: At command under another user

#su - -c "script"
Dave La Mar
Honored Contributor

Re: At command under another user

Travis -
Here's an example from our startup -
nohup su - username -c /path/to_command/command 1>/dev/null 2>/dev/null

In your case the command following -c is as other replies have noted.

You might be wise in adding the username to /var/adm/cron/cron.allow

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Dave La Mar
Honored Contributor

Re: At command under another user

Travis -
Sorry, I meant at.allow.

dl
"I'm not dumb. I just have a command of thoroughly useless information."