B4J Question how to get a b4j job running at reboot raspberry?

MbedAndroid

Well-Known Member
Licensed User
Longtime User
i'm trying to get a b4j program running at reboot of raspberry
I found already lot of comments and examples on the net, but still no lock
Tried Cron: see the cron starts the job, but no running java program
May be someone encounters this problem yet, and solved it?
-Tried to make a batch file: no luck.
Inserted it in cron (as root and as user) @reboot /home/pi java -jar test.jar : no luck
Inserted it in rc.local: no luck

even when i run it every minute i see cron start the bash job, but no action of the program
CRON[20537]: (root) CMD (bash /home/pi/jar-start.sh)

followed this topic : no luck http://raspberrypi.stackexchange.com/questions/13034/executing-a-jar-file-when-raspberry-boots-up

anyone a suggestion?
 

imbault

Well-Known Member
Licensed User
Longtime User
go to /etc
edit rc.local
add those 2 lines according to your needs just befrore the end of rc.local :

cd /home/pi/taboo
/usr/bin/java -jar PushTaboo.jar &
 
Last edited:
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
somehow it still doesnt work...
puzzling....:(
wgtetk.jpg
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
mmm no
i can run a small testprogram as sudo /etc/rc.local
but i wont run at reboot.
the testprogram sends me a mail, so i that way i know it works or not
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

suggest again to try cron as follows.

Create folder /home/pi/scripts

Create a script pushtaboo.sh with content
#!/bin/sh
cd /home/pi/taboo
java -jar pushtaboo.jar

Make pushtaboo.sh executable:
chmod 755 /home/pi/scripts/pushtaboo.sh

Add pushtaboo.sh to cron:
sudo crontab -e
Add at the end of the file:
@reboot sudo /home/pi/scripts/pushtaboo.sh
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
he rwblinn....:)
got some succes...just received a mail from the rasp
but i discovered that it come after i started crontab manually. Seems that rc.local doesnt start crontab or rc.local is not executed....
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
the key of the problem seems to be rc.local not been executed..
trying sudo /etc/init.d/rc.local gives positive results, but it's not been executed after reboot...
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

if you stick using rc.local, checkout if the information here helps.
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
the rc.local is fine, no problems with the script, but it isnt called during bootup, probably due some changes in the past.
dont know what program is calling rc.local. I inserted a line for test which dumps a txt file. During bootup nothing happens, manually i see the dump.

Will have a look at warwound's example
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

I have this problem too, Did you solved this problem ?
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Is /etc/rc.local, not /etc/init.d/rc.local
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Use a cron job.
Example:
To edit: sudo crontab -e.
Add a line like
B4X:
@reboot sudo javapath -jar b4japppath/b4japp.jar&
To list cronjobs: sudo crontab -l.

Notes:
The b4japp.jar must be made executable: sudo chmod a+x b4japp.jar.

Using a script is also an option instead of calling the b4japp.jar. Make the script executable (sudo chmod a+x scriptname.sh).
Script Example:
B4X:
#Set folder containing jar
cd /home/pi/b4jappfolder

#Start the b4japp
/usr/bin/java -jar b4japp.jar&
printf "b4japp started"
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
here a update about this issue
my sd card was broken, so i installed a new rasbian.
And to my surprice the command in rc.local is working now.
somehow something was broken in the previous installation
 
Upvote 0
Top