LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   trying to launch obexpushd at boot with rc.local or crontab but not working. pls help (https://www.linuxquestions.org/questions/linux-newbie-8/trying-to-launch-obexpushd-at-boot-with-rc-local-or-crontab-but-not-working-pls-help-4175636341/)

scidoot 08-14-2018 08:31 AM

trying to launch obexpushd at boot with rc.local or crontab but not working. pls help
 
When I use terminal everything works. This is my command:

sudo obexpushd -B -n -o '/home/pi/files'

OR

sudo obexpushd -B -o '/home/pi/files'

How can I get this to start at boot?
I tried editing rc.local and adding this line:

-------------------------
sudo obexpushd -B -o '/home/pi/files' &
exit 0
-------------------------
And with no success. I cant figure out why!
I even found a tutorial that follows the same steps and works
https://hackaday.io/project/3917-pi-...oth-adventure#
pls help im really frustrated been doing this for a couple of days

rtmistler 08-14-2018 10:20 AM

You should put a script into your /etc/init.d directory.

Note other scripts in there, such as S02Modules or something similar.

You can make an executable script S##<name> where the ## is a number from 01-99. Suggest you use a higher number. They go in order from 01-99 as the system boots.

A common mistake is that someone fails to make the script file executable, or the scripts are owned by a user as opposed to being owned by root.

You will not need sudo because the init script will run as root.

You should continue to use the & at the end of your command, this will have the command run in the background, or as a non-blocking script when the system boots.

The script can be as simple as:
Code:

obexpushd -B -o '/home/pi/files' &
Suggest you use the full path for obexpushd. You may also choose the -o target file to be something other than a location in the /home/pi directory, perhaps /tmp will be more suitable. /tmp is a RAM based file system, so it will not be a permanent copy of files, but it is one option. I can't tell if the -o argument is merely for log location or if the program needs to read information from that setting.

michaelk 08-14-2018 11:07 AM

In addition, it depends on what distribution/version your running on the Pi. The latest version of raspian is based upon Jessie so it will use systemd versus sysv init.

If using a systemd distribution I assume you need to enable the rc-local service as well as change the rc.local permissions for execution just like a regular OS. I assume that the rc-local service already exists.

sudo systemctl enable rc-local
sudo chmod +x /etc/rc.local

scidoot 08-15-2018 12:01 PM

Unfortunately, I still can't get things working. What works is making a script in init.d, using chmod and update-rc to give permissions and register the .sh file to run at boot.
I know myfile.sh has root access, and I can run the file manually, but it doesn't run at boot. And don't I need #! /bin/sh at the start of a init.d file to get it to work at boot? I would most appreciate it if sbd could
answer with the full code I need to insert into /etc/init.d/my file.sh as I think that's where my problem lies. Otherwise, if anyone could help me on discord @audekx#9305 I promise to post what helped me back on the forum!
Thx in advance

ondoho 08-16-2018 01:02 AM

Quote:

Originally Posted by scidoot (Post 5892023)
answer with the full code I need to insert into /etc/init.d/my file.sh as I think that's where my problem lies.

i doubt this is going to happen.
instead, you should make an effort to answer all the questions asked and suggestions made so far.

my own take:
- surely something must be in the logs if it fails
- 'command & exit' might fail. probably best to remove the 'exit 0'
- anyhow show us the complete script


All times are GMT -5. The time now is 12:33 AM.