Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: risshuu on November 25, 2016, 11:09:39 PM
-
I am running picore.
1. I have a script I want to run at startup. I have tried a few things; currently using: su bob -c "python /home/bob/fauxmo.py" -s /bin/bash
in the bootlocal file. So far, nothing has worked.
2. I want cron to start at boot. I have mounted the boot partition and modified both cmdline.txt and cmdline3.txt by adding cron at the end of it. Neither start cron. I have also tried putting /etc/init.d/services/crond start
in the bootlocal file. Nothing works.
-
I am running picore.
1. I have a script I want to run at startup. I have tried a few things; currently using: su bob -c "python /home/bob/fauxmo.py" -s /bin/bash
in the bootlocal file. So far, nothing has worked.
Does it work if you try it in the console?
There are many issues.
- do not use bob, use default tc user
- make sure you really need bash, default is BusyBox ash
- if you need bash, install from repo
- bash is in /usr/local/bin, not /bin
-
Yes. It does. I have to run it from the command line in order for it to work instead of it running automatically from bootlocal.
-
Hi,
if you put your script in the bootlocal, it will be startet as root, so why using su bob.
Also try to use absolute path for su and python.
I'm new to piCore too, but I would do it this way:
Try to put:
#!/usr/local/bin/python -O
in the header of your python script. Make your script executable:
sudo chmod +x /home/bob/fauxmo.py
Then add:
/home/bob/fauxmo.py
in /opt/bootlocal.sh
And don't forget to backup.
-
Running it as root by just using /home/bob/fauxmo.py in /opt/bootlocal doesn't work. Not even when changing the first line as you suggested. (I'm using PiCore 8.0, btw)
After a reboot:
root@box:~# ps aux | grep faux
1199 root grep faux
root@box:~# type python
python is /usr/local/bin/python
-rwxr-xr-x 1 bob nogroup 15.8K Nov 27 21:30 fauxmo.py
Yet, it works fine on the command line; either the way I had it (running as my other user) or running it as root with the first line different.
root@box:/home/bob# ./fauxmo.py &
root@box:/home/bob# ps aux | grep fauxmo.py
1253 root {fauxmo.py} /usr/local/bin/python -O ./fauxmo.py
1260 root grep fauxmo.py
Cron seems to be starting now, though. I don't know how or why, but maybe adding crond start
into bootlocal did it. At least that works, though.
-
Cron seems to be starting now, though. I don't know how or why, but maybe adding crond start
into bootlocal did it. At least that works, though.
Well, crond must be started. Otherwise doesn't work.
-
What is the output of the syript started in bootlocal.sh? Are there any messages?
-
Cron seems to be starting now, though. I don't know how or why, but maybe adding crond start
into bootlocal did it. At least that works, though.
Well, crond must be started. Otherwise doesn't work.
Yes; my point was I tried the boot flag, and the line in my first post and neither seemed to work.
-
What is the output of the syript started in bootlocal.sh? Are there any messages?
No, there aren't any messages.
-
What is the output of the syript started in bootlocal.sh? Are there any messages?
No, there aren't any messages.
-
Okay, so, I don't know why it wasn't working before, but now cron works fine with just the bootcode. I still can't get my script to start, though.
-
I decided to just create a script that fires off every minute via cron.
#!/bin/bash
if [ $(ps aux | grep fauxmo.py | grep bob | wc -l) -eq 0 ]
then
su bob -c "python /home/bob/fauxmo.py" -s /bin/bash
fi
This seems to work for now. I tried it with @reboot as well, but that never worked.
-
FWIW:
I've started python scripts in bootlocal.sh like this:
python /home/tc/squeezelite_switches1.py &
The ampersand (&) makes it a background process, which has to be added otherwise the bootlocal.sh script would wait untile the command was finished before executing the next statements.
-
Thanks for the suggestion. I just tried this and it didn't work for me.