Skip to content

Instantly share code, notes, and snippets.

@fenwick67
Last active June 12, 2017 11:59
Show Gist options
  • Select an option

  • Save fenwick67/034477103a037d19b0506e7a11f5da2c to your computer and use it in GitHub Desktop.

Select an option

Save fenwick67/034477103a037d19b0506e7a11f5da2c to your computer and use it in GitHub Desktop.
Start on Boot options

options for starting a service on boot in Linux (easy to hard):

rc.local

easy!

Just put your commands in rc.local and they will run ONCE on boot.

This file needs to be executable, and it also needs to exit.

#!/bin/sh

echo "rc.local worked" >> /var/log/itworked.log

nohup su - USER_FOOBAR -c /PATH/TO/MY_APP &

@reboot cron job

NOTE! Does not work in every single case

crontab -e

@reboot echo "cron @reboot worked" >> /var/log/itworked.log

init.d

cp /etc/init.d/skeleton /etc/init.d/myservice

then edit the first few lines of myservice to run your application instead

then...

service myservice start
service myservice stop

reference here

Bonus round: Windows

Userland programs:

Hit win+r, then run shell:common startup. This will open the startup dir, which contains userland stuff that runs when they log in.

Services:

sc.exe create <new_service_name> binPath= "<path_to_the_service_executable>"

You must have quotation marks around the actual exe path, and a space after the binPath=.

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment