Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

running a program at start up

Tue Jan 15, 2013 9:05 pm

It is any way possible for a program to start running automaticly when the pi starts? My robot I am using my pi to control is very small and has no room for any type of screen or keyboard and I think it would be a pain to connect one everytime it starts up.


repton
Posts: 93
Joined: Sat Mar 17, 2012 6:06 pm
Location: Aberdeenshire, UK
Contact: Website

Re: running a program at start up

Wed Jan 16, 2013 4:47 am

Either a cron job @reboot as suggested above or stick it in /etc/rc.local is the other common way of doing it.

The advantage of the former is it makes it easy for a non root user to do it, the advantage of the latter is it doesn't rely on cron working.

Paul
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/

necc
Posts: 25
Joined: Thu Aug 30, 2012 10:55 pm

Re: running a program at start up

Wed Jan 16, 2013 10:40 am

rc.local is the way to go

Hoagie
Posts: 119
Joined: Sun Sep 23, 2012 7:19 pm

Re: running a program at start up

Wed Jan 16, 2013 12:55 pm

I use this script to run my electricity meter monitoring program. I run this from a cron job every 5 minutes.

Code: Select all

#!/bin/bash

if [ `pgrep MeterMonitor` ]
then
        echo Already running - wont start
else
        echo Starting MeterMonitor
        nohup /home/geoff/meter/MeterMonitor >/dev/null &
fi

Return to “Automation, sensing and robotics”