简体   繁体   中英

Running a command on startup

I want to run this command on my ubuntu server installation on startup:

~/factorio/bin/x64/factorio --start-server-load-latest --server-settings ~/factorio/data/server-settings.json

I tried putting this code in the /etc/rc.local directory:

~/factorio/bin/x64/factorio --start-server-load-latest --server-settings ~/factorio/data/server-settings.json || exit 1
exit 0

And the command doesn't run on startup. I know that the command runs when I type it into the command line, but it won't run for some reason when I put it in the /etc/rc.local file. Can anyone tell me where the error is in my code or another way that I could get this command to run on boot?

Open crontab.

 sudo crontab -e

Then try adding you command as root to the bottom.(use nano editor).

 @reboot root ~/factorio/bin/x64/factorio --start-server-load-latest --server-settings ~/factorio/data/server-settings.json

Note that this will run under root so you will need to change the path of every file from '~/call' to '/full/path/to/file'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM