Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

On 10.04 Lucid, how can I add a script to run at startup as another user?

Will I add a script someplace like /etc/init.d/myscript ? Or is it better to put it in the cron file for root as @reboot and the exec command? Or something completely different?

I'm new to this (sorry) but I have been googling without much luck. Links to tutorials would be fine as well, I'm just feeling a little lost not knowing where to start...

share|improve this question
    
Depending on what you want to run and when ... If you want it to run at boot, put it in /etc/rc.local By default it will run as root. To run it as another user, use sudo sudo -u user_to_run_as <command> If you want to run something when you log in, that is different , gnome-session-properties –  bodhi.zazen Dec 9 '11 at 2:40

1 Answer 1

up vote 1 down vote accepted

Take a look at this question on StackOverflow. It suggests something like this -

Call visudo and add this:

user1 ALL=(user2) NOPASSWD: /home/user2/bin/test.sh

The command paths must be absolute! Then call sudo -u user2 /home/user2/bin/test.sh from a user1 shell. Done.

That way you just put the script to run at startup under Startup Applications (System -> Preferences-> Startup Applications) and it'll run on startup

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.