georgestewart88
Posts: 83
Joined: Fri Apr 15, 2016 6:19 am

Running script at boot, as root (or www-data?)

Tue Apr 19, 2016 10:12 am

Hi Everyone,

I am hoping you may be able to help. I have a log file that is updated by the user www-data through php. I want a script to run on boot that also updates this log, but the only way I can think of doing this is as root, since I can't log into www-data. Is there a way I can run a python script at boot, as root? or as www-data?

Thanks!

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Running script at boot, as root (or www-data?)

Tue Apr 19, 2016 10:16 am

just put the script into /etc/rc.local, which is run by root during the boot.

Koeshi
Posts: 228
Joined: Sun Mar 20, 2016 11:16 am

Re: Running script at boot, as root (or www-data?)

Tue Apr 19, 2016 11:40 am

shuckle wrote:just put the script into /etc/rc.local, which is run by root during the boot.
Will this work for scripts that you want to run continuously during operation?

User avatar
dbsteimle
Posts: 10
Joined: Tue Apr 19, 2016 10:28 am
Location: Raleigh, NC
Contact: Website

Re: Running script at boot, as root (or www-data?)

Tue Apr 19, 2016 1:04 pm

Put an & after the script to run in the background:

Code: Select all

/home/me/myscript.sh &
The "Temperature Log" lab is a good tutor for this. https://www.raspberrypi.org/learning/temperature-log/
David Steimle
http://davidsteimle.com/

Koeshi
Posts: 228
Joined: Sun Mar 20, 2016 11:16 am

Re: Running script at boot, as root (or www-data?)

Wed Apr 20, 2016 9:13 pm

dbsteimle wrote:Put an & after the script to run in the background:

Code: Select all

/home/me/myscript.sh &
The "Temperature Log" lab is a good tutor for this. https://www.raspberrypi.org/learning/temperature-log/
That is just what I wanted, I have a python script putting out temperature readings to the PiGlow LED board, just wanted to have it going in the background without keeping a terminal window open.

Return to “Python”