How can i start a python script.py after a reboot as user xy in Debian Squeeze automatically?
Asked
Active
Viewed 655 times
2 Answers
1
Put an entry in rc.local with something similar to the following:
su user_xy -c "script.py"
to execute the program as that user:
su - user_xy -c "script.py"

89c3b1b8-b1ae-11e6-b842-48d705
- 1,465
- 1
- 13
- 22
-
you can add sudo too ... `sudo su - user_xy -c "script.py" ` – Daniel t. Mar 11 '13 at 16:50
-
1@Danielt. I would strongly advise *against* using `sudo` in rc startup scripts (mainly because those scripts are already running as root). – voretaq7 Mar 11 '13 at 17:01
-
But how can i run it as user_xy, so the process is owned by user_xy? – Ulfric Storm Mar 11 '13 at 20:16
-
su - user_xy -c "script.py" note the dash. updated answer, accept it if you don't have additional questions – 89c3b1b8-b1ae-11e6-b842-48d705 Mar 11 '13 at 20:32
0
You can use @reboot entry in crontab of user root or user xy. Debian cron supports such entries.
man -S5 crontab
string meaning
------ -------
@reboot Run once, at startup.

AnFi
- 6,103
- 1
- 14
- 27