Skip to content
Advertisement

bash script to auto run on boot, make screen, execute a command and detach

I am using Centos 7 and on boot I would like to:

  • Make a screen
  • Execute a command: osrm-routed –algorithm=MLD ~/osrm-backend/profiles/australia-latest.osrm
  • Detatch from screen (possibly not needed, just as long as I can access it myself after its running in future)

Here is something I have thought about, although not correct and wont work

filename: mapstart.sh Contents of file:

JavaScript

With your help with the script. I am not sure the best way to run that on boot with centos 7.

Appreciate your help and input.

Advertisement

Answer

For those who would like to know. The issue was with OSRM and centos. I was able to get it running using the full paths of everything and the following in crontab -e

To get the full path of osrm-backend i ran the command of:

JavaScript

It returned the result of:

JavaScript

That then enabled me to add the full path of the command I was trying to run from crontab -e which is required. From there it worked running the below in crontab -e

JavaScript

break down of all the above:

runs command at reboot only:

JavaScript

full path to screen command:

JavaScript

create screen with name of pistartup and detach:

JavaScript

my particular command i wanted to run inside the screen:

JavaScript

Now when ever the machine is rebooted. it has created a screen and run my command. To resume the screen manually If i ever wanted to, i could issue the command of:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement