-1

I have three terminal commands that I would like to execute when server boots up. How can I achieve this? I have seen many solutions, but none of them seems to be simple and working. Here are the referrals:

https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-boot-init-shutdown-run-boot.html https://www.centos.org/forums/viewtopic.php?f=47&t=48140

Here are the terminal lines which I want to execute when system starts:

root@server:
cd home/user/public_html/app/
forever -o outG.log -e errG.log  start app1/game_server.js
forever -o outM.log -e errM.log  start app2/main_server.js
forever -o outN.log -e errN.log  start app3/node.js
Marko Tamburic
  • 181
  • 1
  • 1
  • 10

1 Answers1

2

In scripts quite often problems are caused by ambiguous paths so rather than "home/user/public_html/app/" use the absolute path "/home/user/public_html/app/" .

A second common problem in scripts is your PATH is different. So again instead of "forever" either use the absolute path along the likes of /usr/bin/forever or locally set PATH in your script.

rc.local is indeed a common place to start services at boot time.

HBruijn
  • 72,524
  • 21
  • 127
  • 192