Hey, hoping to get some advice from someone who has dealt with this before.
I am running Raspbian, installed via Noobs, have run the sudo apt-get update, sudo apt-get upgrade, sudo rpi-update, and sudo apt-get dist-upgrade, so it should be all up to date.
Everything is running quite well, but I am running into problem getting pyload to auto-start on reboot.
I have added the following lines via sudo crontab -e
@reboot kodi-standalone
@reboot /usr/share/pyload/pyLoadCore.py --daemon
@reboot /home/pi/.btsync/btsync --config /home/pi/.btsync/sync.conf
When I boot my pi up it goes through Noobs, automatically boots into my last used distro (Raspbian), then continues to boot. It gets to the login prompt, waits there briefly, then Kodi launches and takes over the screen. By SSH in I can see what is running and what is not. BTsync is running nicely, and accessible via the web GUI, however, pyload does not start. If I use the terminal and type in /usr/share/pyload/pyLoadCore.py --daemon then it starts and runs just fine. If I enter service pyload start into the terminal it starts just fine. I even tried adding my own script called pyload.sh which contains the /usr/share/pyload/pyLoadCore.py --daemon and that works just fine if entered into /etc/profile (though only AFTER logging in with username and password, whereas I want to start pyload prior to logging in)
I have tried putting @reboot service pyload start into the the cronjob, it does not work
I have tried referencing my pyload.sh script in crontab, it also does not work
I am unsure about why these are not working, and so I am scared to try to add my script into the rc.local for fear of grinding the boot process to a halt if for some reason the requisite services are not available to start pyload at that point in the boot and that is why this isn't working.
I have enabled and examined the cron log and find no errors in it.
What could be the problem, and how can I fix it?
Thanks!
- expandables
- Posts: 654
- Joined: Fri Jun 27, 2014 7:34 pm
- Location: Neverland with Michael Jackson
Re: Cronjob starting some but not all jobs...
Can you run the script in

Code: Select all
.bashrc

By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
Re: Cronjob starting some but not all jobs...
hmm I am not familiar with .bashrc, can you give me an example of what the correct input for my case would be, and I can try it? (program I'm trying to run is at /usr/share/pyload/pyLoadCore.py)
Thanks!
Thanks!
- expandables
- Posts: 654
- Joined: Fri Jun 27, 2014 7:34 pm
- Location: Neverland with Michael Jackson
Re: Cronjob starting some but not all jobs...
rpi25 wrote:hmm I am not familiar with .bashrc, can you give me an example of what the correct input for my case would be, and I can try it? (program I'm trying to run is at /usr/share/pyload/pyLoadCore.py)
Thanks!
Code: Select all
sudo nano .bashrc
Code: Select all
sudo sh /home/pi/pyload.sh

By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
- expandables
- Posts: 654
- Joined: Fri Jun 27, 2014 7:34 pm
- Location: Neverland with Michael Jackson
Re: Cronjob starting some but not all jobs...
Hey instead of you doing all 3 of these in cronjob why not make a single script that launches all 3 of them and put it in
I guess you can name the script

Code: Select all
.bashrc
Code: Select all
startup.sh

By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
Re: Cronjob starting some but not all jobs...
That's a good idea, I will likely do it.
I guess I am a bit confused, why is .bashrc better for cronjob than this? How do either of them compare with init.d? Linix noob here, lol.
I guess I am a bit confused, why is .bashrc better for cronjob than this? How do either of them compare with init.d? Linix noob here, lol.
Re: Cronjob starting some but not all jobs...
Well, your idea of adding my script for pyload to .bashrc worked like a charm, wizard!
But seriously, where the heck can I read a good primer on all the various ways there are of automating user created scripts? I was really liking cronjob b/c I felt I had a good handle on it, until it stopped working for me, lol. Oh well
But seriously, where the heck can I read a good primer on all the various ways there are of automating user created scripts? I was really liking cronjob b/c I felt I had a good handle on it, until it stopped working for me, lol. Oh well
Re: Cronjob starting some but not all jobs...
OK, here's one thing I'm noticing.
Now whenever I SSH into my pi using putty, after putting in the login info it sits there and waits for a prolonged period of time, then pops out with
"Daemon PID XXXX"
I believe it is trying to relaunch my .bashrc line which calls upon my command to start pyLoadCore.py --daemon, each time I am opening a terminal.
This is less than ideal, any way to stop this from happening?
Now whenever I SSH into my pi using putty, after putting in the login info it sits there and waits for a prolonged period of time, then pops out with
"Daemon PID XXXX"
I believe it is trying to relaunch my .bashrc line which calls upon my command to start pyLoadCore.py --daemon, each time I am opening a terminal.
This is less than ideal, any way to stop this from happening?
- expandables
- Posts: 654
- Joined: Fri Jun 27, 2014 7:34 pm
- Location: Neverland with Michael Jackson
Re: Cronjob starting some but not all jobs...
Your script has no exit so it will continue to run.rpi25 wrote:OK, here's one thing I'm noticing.
Now whenever I SSH into my pi using putty, after putting in the login info it sits there and waits for a prolonged period of time, then pops out with
"Daemon PID XXXX"
I believe it is trying to relaunch my .bashrc line which calls upon my command to start pyLoadCore.py --daemon, each time I am opening a terminal.
This is less than ideal, any way to stop this from happening?
Try at the end of your script
Code: Select all
exit 0

By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.
Re: Cronjob starting some but not all jobs...
Yes, that is exactly what it is doing. The .bashrc file is run every time you log into a terminal. If you are going to run it from there you should put some code in to check if it is already running before trying to start it. The "pidof" command is one handy way to find if something is running.rpi25 wrote:OK, here's one thing I'm noticing.
Now whenever I SSH into my pi using putty, after putting in the login info it sits there and waits for a prolonged period of time, then pops out with
"Daemon PID XXXX"
I believe it is trying to relaunch my .bashrc line which calls upon my command to start pyLoadCore.py --daemon, each time I am opening a terminal.
No need. If you don't put an exit at the end of the script it will exit with the status of the last command it executed. The reason the rc.local script has exit 0 is that it doesn't want to report failure and hang up the boot if anything in it fails.expandables wrote:Your script has no exit so it will continue to run.
Try at the end of your script
Code: Select all
exit 0
Re: Cronjob starting some but not all jobs...
OK cool thanks for confirming that.rpdom wrote:Yes, that is exactly what it is doing. The .bashrc file is run every time you log into a terminal. If you are going to run it from there you should put some code in to check if it is already running before trying to start it. The "pidof" command is one handy way to find if something is running.rpi25 wrote:OK, here's one thing I'm noticing.
Now whenever I SSH into my pi using putty, after putting in the login info it sits there and waits for a prolonged period of time, then pops out with
"Daemon PID XXXX"
I believe it is trying to relaunch my .bashrc line which calls upon my command to start pyLoadCore.py --daemon, each time I am opening a terminal.
No need. If you don't put an exit at the end of the script it will exit with the status of the last command it executed. The reason the rc.local script has exit 0 is that it doesn't want to report failure and hang up the boot if anything in it fails.expandables wrote:Your script has no exit so it will continue to run.
Try at the end of your script
Code: Select all
exit 0
I am familiar with pidof, how can I write that into the .bashrc? I assume some sort of if else statement? I've never worked with those outside of my TI-83 back in the day xD haha.
So like maybe,
Code: Select all
if pidof python =/= 0, then /usr/share/pyload/pyLoadCore.py --daemon
Also, regarding script exit. I believe that because it is daemonizing the program, that is the exit. For instance, if I launch pyload from the terminal and do not put the --daemon in, it runs through its initialization text then just sits there and does not return to the command prompt. But, if I do put the --daemon in then it takes maybe ~5-10 seconds, and does not show any of the normal output put simply says daemon pid = XXXX and then bumps me back to the command prompt, and pyload is running in the background. So I think based on this the daemon is an exit of sorts?
Re: Cronjob starting some but not all jobs...
Can any of you nice folks who have been helping me out in this thread explain what the proper syntax would be to have my .bashrc script check if pyload is already running before trying to relaunch it each time I open a terminal?
Thanks!
Thanks!
Re: Cronjob starting some but not all jobs...
Ok, something like this?
You might need to tweak it a bit, but that should give you the general idea.
You could put the test at the beginning of pyload.sh instead, so it'll be checked however it is run.
Code: Select all
# Check if "pyLoadCore.py" is running. If not, run pyload.sh
if ( ! pidof -x pyLoadCore.py >/dev/null )
then
sudo sh /home/pi/pyload.sh
fi
You could put the test at the beginning of pyload.sh instead, so it'll be checked however it is run.
Code: Select all
# Check if "pyLoadCore.py" is already running first.
if ( pidof -x pyLoadCore.py >/dev/null )
then
echo "pyLoadCore is already running"
exit 0
fi
# Now start pyLoadCore.py
- RaTTuS
- Posts: 10748
- Joined: Tue Nov 29, 2011 11:12 am
- Location: North West UK
- Contact: Twitter YouTube
Re: Cronjob starting some but not all jobs...
.bashrc and .bash_profile
are slightly different things
I tend to use things like
http://www.raspberrypi.org/forums/viewt ... =29&t=7192
to auto start scripts
so setup a terminal in inittab to do some stuff that I want
then have in .bashrc something similar to
this then will check to see if the current terminal is tty1 [i.e. the first one generally] and then it will launch my script
also a lot of stuff should not be run as root [or need to be ]
so if you put things in rc.lcoal they will get run as root unless you do something like :-
su -u username /full/path/to/command with args
are slightly different things
I tend to use things like
http://www.raspberrypi.org/forums/viewt ... =29&t=7192
to auto start scripts
so setup a terminal in inittab to do some stuff that I want
then have in .bashrc something similar to
Code: Select all
if [ $(tty) == /dev/tty1 ]; then
./script
fi
also a lot of stuff should not be run as root [or need to be ]
so if you put things in rc.lcoal they will get run as root unless you do something like :-
su -u username /full/path/to/command with args
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
WARNING - some parts of this post may be erroneous YMMV
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
Re: Cronjob starting some but not all jobs...
OK thanks for the tips, appreciate it!