How to run a script on linux startup? Generic solution for linux?
Use crontab #crontab -e; @reboot sh $HOME/test.sh or Add your script to /etc/init.d/ directory, Update your rc run-levels: $ update-rc.d myScript.sh defaults NN where NN is the order in which it should be executed. 99 for example will mean it would be run after 98 and before 100.
# create and install new crontab
crontab /home/username/filename
crontab -u (whoami) $HOME/aviscripts/avi_crontab
@reboot cd /home/me/ && sh myscript.sh
grep CRON /var/log/syslog
journalctl -u cron.service
journalctl -t CROND
logger "have more fun" > /var/log/mycustomlog
journalctl -u cron.service | grep -A9 -B5 HOME/aviscripts/on_startup_script.sh
May 27 13:09:07 mehenwal CRON[694]: pam_unix(cron:session): session opened for user avi by (uid=0)
May 27 13:09:07 mehenwal CRON[731]: (avi) CMD (bash $HOME/aviscripts/on_startup_script.sh)
May 27 13:09:07 mehenwal CRON[694]: (CRON) info (No MTA installed, discarding output)
May 27 13:09:07 mehenwal CRON[694]: pam_unix(cron:session): session closed for user avi