Auto-Start Programs at Boot Using Crontab with Shell Access


If you have custom code on a groov EPIC that you want to run automatically every time the system boots or reboots, consider using the crontab tool to auto-start it for you.

You can view existing cron jobs with crontab -l , and make changes using the crontab -e command, which will open the crontab file with the text editor vi.

If you’re unfamiliar with vi you should know that it launches in “command mode”, you’ll need to press the i key to enter “insert mode”, make any changes to the file, and then press Esc to go back to command mode. From there you can type :x to save and close the editor, or :q! to force quit without saving.

To add a new cron job that will start at boot, put @reboot in front of your command, and end with an ampersand (&) to run it in the background. Make sure that you include the full path to any programs or files you reference. For example, I put a simple Python script in the unsecured file area, which has the path /home/dev/unsecured, so I added the following line to my crontab to make it run at boot:

@reboot python /home/dev/unsecured/ &

Using i to start inserting new text, then Esc and finally :x to save and quit. Once it’s added, double check it with crontab -l and then reboot through groov Manage to test it.

If you start a process in the background that you want to end later, you can use htop or pgrep to find the process ID (PID) and kill $PID to kill the process. For example, I found my Python PID with the command pgrep -f which returned 3310, so a simple kill 3310 stopped it running.

Happy coding!