On an amazon linux instance, I have two scripts called start_my_app
and stop_my_app
which start and stop forever (which in turn runs my node.js app). I use these scripts to manually start and stop my node app. So far so good.
My problem: I also want to set it up such that start_my_app
is run whenever the system boots up. I know that I need to add a file inside init.d
and I know how to symlink it to the proper directory within rc.d
, but can't figure out what actually needs to go inside the file that I place in init.d
. I'm thinking it should be just one line, like, start_my_app
, but that hasn't been working for me.
You can do it :
then use this command
Please see this page on Cyberciti.
Set a crontab for this
after every startup it will run the test script.
A simple approach is to add a line in
/etc/rc.local
:or if you want to run the command as root :
(the trailing ampersand backgrounds the process and allows the rc.local to continue executing)
If you want a full init script, debian distro have a template file, so :
and adapt it a bit.
This simple solution worked for me on an Amazon Linux instance running CentOS. Edit your
/etc/rc.d/rc.local
file and put the command there. It is mentioned in this file that it will be executed after all other init scripts. So be careful in that regards. This is how the file looks for me currently.. Last line is the name of my script.for some people this will works You could simply add the following command into System > Preferences > Startup Applications:
Just have a line added to your crontab..
Make sure the file is executable:
To edit crontab file:
Line you have to add:
That simple!