9
3
I want to run /home/myuser/go.py
How do I make that run in the background, everytime my linux machine boots up?
9
3
I want to run /home/myuser/go.py
How do I make that run in the background, everytime my linux machine boots up?
8
Simple way
You can add this script into /etc/rc.local
file (before exit
line), e.g.
/home/myuser/go.py &
Where &
at the end will run the script in the background.
Make sure that you've execution flags. To test it, simple run from the terminal:
sh /etc/rc.local
2
You can put a script in the /etc/init.d/
directory (eg: /etc/init.d/go.py
) for anything you want to run at bootup time.
http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian
7I prefer /etc/rc.local
as you do not need to change the run-level links. – Dirk Eddelbuettel – 2010-06-22T19:05:13.960
@DirkEddel - I agree to that! – BloodPhilia – 2010-06-22T19:12:05.363
Perhaps you should add this as a separate answer so it can be voted up? – Steve Homer – 2010-06-22T20:48:25.947
2
There are many ways to do this (depending on which distribution of linux you are using there are different tools that are offered).
The easiest way is simply adding the script to /etc/init.d and then running the command
chmod +x go.py
update-rc.d go.py defaults
If you already set up the service, you may also do so via the chkconfig command (that is if the command is available).
In that case, this command should work:
chkconfig --level 35 go.py on
Check out THIS WEBSITE, more specifically the "Using chkconfig to Start Daemons at Each runlevel" and "Using sysv-rc-conf to Start Daemons at Each runlevel" sections.
0
cron has a special @reboot
option that allows for this. Nice and simple.
A normal cron task might be:
* * * * * /path/to/app
A @reboot
cron task might be:
@reboot /path/to/app
general what-happens-on-ubuntu-startup here: http://superuser.com/questions/151330/ubuntu-control-the-init-startup ... this might be "close enough" to consider a duplicate.
– quack quixote – 2010-06-22T19:46:07.487