John Minton,
This looks really helpful. Also I was thinking about making an icon on the Desktop to run a bash script, probably something very easy but I am very ignorant of bash and Linux, so will have to study up on cron and bash, and here I thought all I had to learn was Python and Tkinter and Beaglebone I/O. :-)
Thanks,
John

On 4/14/2016 11:48 AM, [email protected] wrote:
I was also looking to run my python script on boot so I did a couple things that worked as a a short term solution. I added 2 lines to my crontab, an @reboot line to run the program when the device starts up as well as a bash script to ensure the program is still running.

(Replace main.py with your program name and make sure it doesn't match anything else that may be running)

crontab -e

# Runs when the system boots:
@reboot sudo python /path/to/program.py

# Runs every minute and checks that your program is running:
* * * * * sudo bash /path/to/check_process.bash


(Just a note, if you need multiple programs to run on boot, replace "@reboot sudo python /path/to/program.py" with a bash script, and place the things you need to run on boot in that bash file.)



check_process.bash:

#!/bin/bash

process_id=`ps aux | grep "YOURPROGRAM.py" | grep -v "grep"`;

if [ -z "$process_id" ]; then

    echo "process not running for certain."

    cd /PATH/TO
    cd /PATH/TO/YOURPROGRAM.py &

else

    echo "YOURPROGRAM.py seems to be running";

fi

The only down side is that if your program crashes, you have to wait up to a minute for the crontab to run the check_processes.bash, but otherwise is pretty solid.

Now I am also looking for how to run my script as a system service.




On Thursday, April 7, 2016 at 9:18:43 PM UTC-7, John Baker wrote:

    My program runs fine but requires that I use putty.exe and type
    sudo python myprog.py to run it. I have been reading about
    systemctl and have written a service file and put it in
    /lib/systemd/system. It's called paint-flow.service, listing
    below. I have.. enabled it with systemctl enable
    paint-flow.service with no errors and tried systemctl start
    paint-flow.service with no errors but my program doesn't seem to
    start. When I check the status I get "code=exited, status =
    203/EXEC" which doesn't tell me anything, at least nothing that I
    understand.

    Also I tried the same thing with a one-line Hello.py program and
    same results.

    Any help with this newbie problem, please?

    [Unit]
    Description=Paint flow control program

    [Service]
    WorkingDirectory=/home/debian/Desktop/
    ExecStart=/home/debian/Desktop/python SimB.py
    SyslogIdentifier=SimB
    Restart=on-failure
    RestartSec=5

    [Install]
    WantedBy=multi-user.targetI am using Debian 3.8.13



    John

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/ULeYE9kjqZ4/unsubscribe. To unsubscribe from this group and all its topics, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
For more options, visit http://beagleboard.org/discuss
--- You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to