Run program, or service at startup – Ubuntu

Easy way to run common programs or commands at startup / reboot using crontab

It’s useful because you can change directory as many times as you like in the script file without worrying about cron being able to use absolute paths etc.

crontab -e

@reboot /home/yourusername/startup.sh

Create the following file called startup.sh in your home directory

This example auto loads Unreal IRC and it’s associated services, the sleep command makes the script pause for that number of seconds.

You can add as many additional bash commands etc as you’d like and they should only start to load once the previous command has been successfully run (It may still be useful to use the sleep command for some programs / services)

# ======== PASTE THIS ============

#!/bin/bash

PATH=/usr/sbin:/usr/bin:/sbin:/bin

# rest of script follows

cd /home/youruser/Unreal3.2/
./unreal start
sleep 20
cd /home/youruser/services/
./services

# ========== END ==========

Print Friendly, PDF & Email

More Like This


Categories


Linux
  • Post a comment