Summary of shell or linux problems

Automatically start a service or script after linux runs

There are several methods:

1. The easiest is to add a startup service or execute a script statement to the /etc/rc.d/rc.local file.

2. Add a script to control the service in the /etc/rc.d/init.d folder

3.......


A little trick: put the command into the background to run, it does not affect the execution of the script in the current window -> just add & after the command

E.g: 

node app.js >> app.log & 

echo "startup successful"

It means: execute the node app and save the printed content to the log file app.log, and the interface outputs "startup successful". (you can try without &)


The difference between >> and > : >> is to append the file content, > is to overwrite the file content

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325690884&siteId=291194637