torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

[Solved]Need to find command for crontab on reboot

Sun Feb 23, 2020 4:28 pm

Hi,

since i have replace my mousse on the pi4 by a wireless mousse logitech M185, i have a failed on the dvb_usb start.
I retry with my old mouse no wireless and i have no the problem for TvHeadend.

It result the TvHeadend server failed without use these 2 commands:

Code: Select all

modprobe -r dvb_usb_af9035
modprobe dvb_usb_af9035
I put theses 2 commands on my Onreboot.sh

So i try to add a command on the crontab but it failed it seems sleep i a while loop?
@reboot sleep 60 && ./script/Onreboot.sh

I try an other one it failed too:
@reboot echo ./script/Onreboot.sh | at now + 1 minutes

I don't know if i need a time shift of 1 minute after the boot, i will check that when the command works.

Failed result of the cronjob:

Code: Select all

Apr 11 18:28:37 LibreELEC crond[284]: user root: parse error at at
Feb 23 17:21:19 LibreELEC crond[284]: user root: parse error at @reboot
Feb 23 17:21:19 LibreELEC crond[284]: user root: parse error at echo
Feb 23 17:21:19 LibreELEC crond[284]: user root: parse error at ./script/Onreboot.sh
Feb 23 17:21:19 LibreELEC crond[284]: user root: parse error at |
Feb 23 17:21:19 LibreELEC crond[284]: user root: parse error at at
Feb 23 17:21:19 LibreELEC crond[284]: time disparity of 457912 minutes detected
Feb 23 17:22:00 LibreELEC crond[284]: USER root pid 812 cmd bash ./script/ventilo.sh
Feb 23 17:23:00 LibreELEC crond[284]: USER root pid 815 cmd bash ./script/ventilo.sh
Feb 23 17:24:00 LibreELEC crond[284]: USER root pid 827 cmd bash ./script/ventilo.sh
Or if you have any other solution to add my command on config or other file load on boot im aware

Just for info extract of my dmesg result:.

Code: Select all

...
[    1.475435] usb 1-1.4: New USB device found, idVendor=046d, idProduct=c534, bcdDevice=29.01
[    1.475444] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    1.475450] usb 1-1.4: Product: USB Receiver
[    1.475456] usb 1-1.4: Manufacturer: Logitech
[    1.483478] input: Logitech USB Receiver as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C534.0001/input/input0
[    1.538883] hid-generic 0003:046D:C534.0001: input,hidraw0: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-0000:01:00.0-1.4/input0
[    1.548009] input: Logitech USB Receiver Mouse as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C534.0002/input/input1
[    1.548231] input: Logitech USB Receiver Consumer Control as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C534.0002/input/input2
[    1.586290] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.602017] input: Logitech USB Receiver System Control as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C534.0002/input/input3
...
[    5.812112] usb 1-1.2: dvb_usb_v2: 2nd usb_bulk_msg() failed=-110
[    5.812143] dvb_usb_af9035: probe of 1-1.2:1.0 failed with error -110
[    5.812212] usbcore: registered new interface driver dvb_usb_af9035
Regards
Last edited by torak666 on Tue Mar 10, 2020 4:35 pm, edited 1 time in total.

epoch1970
Posts: 4478
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Need to find command for crontab on reboot

Sun Feb 23, 2020 5:26 pm

Why not sleep in the script?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

pcmanbob
Posts: 8342
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Need to find command for crontab on reboot

Sun Feb 23, 2020 5:57 pm

Using the first Cron line you posted , 2 points

1. Did you make your Onreboot.sh file executable ?

2. Try changing ./ To the full directory path , were your Onreboot.sh is saved.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Need to find command for crontab on reboot

Mon Feb 24, 2020 6:58 am

Thanks for your quick help
epoch1970 wrote:Why not sleep in the script?
It is important that the sleep is on the script?I think it should be better to see directly if the script is delayed when called and if that works, for me it's not a bad idea
pcmanbob wrote:
Sun Feb 23, 2020 5:57 pm
Using the first Cron line you posted , 2 points

1. Did you make your Onreboot.sh file executable ?
Yes my script is executable i check again this morning

2. Try changing ./ To the full directory path , were your Onreboot.sh is saved.
Ok i wrill try later and post result
regards

epoch1970
Posts: 4478
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Need to find command for crontab on reboot

Mon Feb 24, 2020 1:10 pm

Sleeping in the script would simplify the crontab line, nothing more.
Personally if I had to use cron I would concoct something like "/usr/local/bin/tasks/onreboot 2" with /usr/local/bin/tasks/onreboot like (untested code):

Code: Select all

#!/bin/sh
SLEEP=${1:-0}
[ "$SLEEP" -ne "0" ] && sleep $SLEEP
# Now do stuff ...
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Need to find command for crontab on reboot

Mon Feb 24, 2020 6:51 pm

pcmanbob wrote:
Sun Feb 23, 2020 5:57 pm
Using the first Cron line you posted , 2 points

Try changing ./ To the full directory path , were your Onreboot.sh is saved.
It seems the script is called, i don't know if command are succesfully used but the TvheadEnd client is still failed without manual set my command.

There is an other way to add my command at end of boot execution?

content of my script Onreboot.sh

Code: Select all

modprobe -r dvb_usb_af9035
modprobe dvb_usb_af9035

pcmanbob
Posts: 8342
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Need to find command for crontab on reboot

Tue Feb 25, 2020 9:15 am

If it wont work with cron it likely wont work with any other method, so you need to find out whats happening when you call your script.

first modify your scrip like this

Code: Select all

echo " Start "
modprobe -r dvb_usb_af9035
modprobe dvb_usb_af9035
echo " Finish "
then change your cron line so it looks like this but using the actual path to your script file

Code: Select all

@reboot sleep 60 && /home/pi/script/Onreboot.sh >> /home/pi/errlog.txt 2>&1
now reboot your pi then after 60 seconds or so look in the errlog.txt file and see if there are any errors
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Need to find command for crontab on reboot

Tue Feb 25, 2020 6:45 pm

Hi, i rework script to have a log working on my Kodi so i have no /home/pi directory
and change crontab you wanted i used and it didn't work

crontab:

Code: Select all

@reboot sleep 10 && /storage/script/Onreboot.sh
*/1 * * * *  bash ./script/ventilo.sh
Result after reboot and typ command systemctl status cron -l:

Code: Select all

Apr 11 18:28:37 LibreELEC systemd[1]: Starting Cron daemon...
Apr 11 18:28:37 LibreELEC systemd[1]: Started Cron daemon.
Feb 25 19:33:55 LibreELEC crond[271]: time disparity of 460925 minutes detected
Feb 25 19:34:00 LibreELEC crond[271]: USER root pid 617 cmd bash ./script/ventilo.sh
Feb 25 19:35:00 LibreELEC crond[271]: USER root pid 623 cmd bash ./script/ventilo.sh
Feb 25 19:36:00 LibreELEC crond[271]: USER root pid 653 cmd bash ./script/ventilo.sh
(Just for info there is no problem with my script ventilo.sh)

And my new Onreboot.sh:

Code: Select all

#!/usr/bin/bash
#path_log=$(/storage/script)
echo " Start">>errlog.log
modprobe -r dvb_usb_af9035
modprobe dvb_usb_af9035
echo " Finish">>errlog.log
After reading errlog.log there is no "Start" and "Finish"
If i launch manually script with ./Onreboot.sh the errlog.log there is "Start" and "Finish" write correctly

pcmanbob
Posts: 8342
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Need to find command for crontab on reboot

Tue Feb 25, 2020 6:59 pm

You did not follow my instructions and change you Cron entry, you are missing
>> /home/pi/errlog.txt 2>&1 from the end of the Cron line.

Try

Code: Select all

@reboot sleep 10 && /storage/script/Onreboot.sh >> /storage/script/errlog.txt 2>&1
*/1 * * * *  bash ./script/ventilo.sh
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Need to find command for crontab on reboot

Thu Feb 27, 2020 4:53 pm

pcmanbob wrote:
Tue Feb 25, 2020 6:59 pm
You did not follow my instructions and change you Cron entry, you are missing
>> /home/pi/errlog.txt 2>&1 from the end of the Cron line.

Try

Code: Select all

@reboot sleep 10 && /storage/script/Onreboot.sh >> /storage/script/errlog.txt 2>&1
*/1 * * * *  bash ./script/ventilo.sh
hi,
error with you following instruction could you help me, i just understand the redirection output in a log file the rest of the command is a mistery for me
result of cron status after a reboot:

Code: Select all

   CGroup: /system.slice/cron.service
           └─276 /sbin/crond -f -S
Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at sleep
Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at &&
Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at /storage/script/
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at @reboot
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at sleep
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at &&
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at /storage/script/
Feb 27 17:44:22 LibreELEC crond[276]: time disparity of 463695 minutes detected
Feb 27 17:45:00 LibreELEC crond[276]: USER root pid 802 cmd bash ./script/ventil
Feb 27 17:46:00 LibreELEC crond[276]: USER root pid 805 cmd bash ./script/ventil
crontab -e:

Code: Select all

@reboot sleep 10 && /storage/script/Onreboot.sh >> /storage/script/errlog.txt 2>&1
*/1 * * * *  bash ./script/ventilo.sh
and Onreboot.sh script:

Code: Select all

echo " Start"
modprobe -r dvb_usb_af9035
modprobe dvb_usb_af9035
echo " Finish"
Autorisation of the file log:

Code: Select all

LibreELEC:~/script # ls -als
total 9
     1 drwxr-xr-x    2 root     root          1024 Feb 26 19:31 .
     1 drwxr-xr-x   20 root     root          1024 Feb 26 19:38 ..
     1 -rwxr-xr-x    1 root     root            80 Feb 26 19:30 Onreboot.sh
     1 -rwxr-xr-x    1 root     root            17 Feb 10 19:37 eject.sh
     1 -rwxr-xr-x    1 root     root             1 Feb 25 19:32 errlog.log
     0 -rwxr-xr-x    1 root     root             0 Feb 26 19:31 errlog.txt
     1 -rwxr-xr-x    1 root     root            14 Feb  9 18:35 reboot.sh
     1 -rwxr-xr-x    1 root     root            16 Feb  9 17:13 shut.sh
     2 -rwxr-xr-x    1 root     root          1968 Feb 27 17:41 ventilo.sh
And errlog.txt content after the reboot is empty

Regards

pcmanbob
Posts: 8342
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Need to find command for crontab on reboot

Thu Feb 27, 2020 7:53 pm

These errors

Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at sleep
Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at &&
Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at /storage/script/
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at @reboot
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at sleep
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at &&
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at /storage/script/

Suggest either an error in the line or Cron file possibly hidden characters.

Without physical access to the pi in question I can't provide any further suggestions / help.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Need to find command for crontab on reboot

Fri Feb 28, 2020 12:18 pm

pcmanbob wrote:
Thu Feb 27, 2020 7:53 pm
These errors

Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at sleep
Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at &&
Apr 11 18:28:37 LibreELEC crond[276]: user root: parse error at /storage/script/
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at @reboot
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at sleep
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at &&
Feb 27 17:44:22 LibreELEC crond[276]: user root: parse error at /storage/script/

Suggest either an error in the line or Cron file possibly hidden characters.

Without physical access to the pi in question I can't provide any further suggestions / help.
ok i wrill try to check on notepad++ my crontab file if there is an hidden characters

pcmanbob
Posts: 8342
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Need to find command for crontab on reboot

Fri Feb 28, 2020 1:18 pm

How are you entering the cron line ?

I would normally suggest using crontab -e or for root sudo crontab -e that way a basic sanity check is done before the line is written to the file and there should not be any problem with hidden characters.

You can still have hidden charters if you are editing the cron file directly when using notepad++ if it is not set to use Linux formatting.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Need to find command for crontab on reboot

Mon Mar 02, 2020 5:19 pm

pcmanbob wrote:
Fri Feb 28, 2020 1:18 pm
How are you entering the cron line ?

I would normally suggest using crontab -e or for root sudo crontab -e that way a basic sanity check is done before the line is written to the file and there should not be any problem with hidden characters.

You can still have hidden charters if you are editing the cron file directly when using notepad++ if it is not set to use Linux formatting.
Hi,
i remove all copy from notepad++ and rewrite manually the crontab -e result is the same as last post error on the line.
I have add a script button on my pi to manual set my command, it is not beautiful but it's work. This crontab should have limitation like this one. Thanks for the help

pcmanbob
Posts: 8342
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Need to find command for crontab on reboot

Tue Mar 03, 2020 10:20 am

I still cant understand why your first cron line does not work but the second one does.

what happens if you change the cron line to this

Code: Select all

@reboot /storage/script/Onreboot.sh >> /storage/script/errlog.txt 2>&1
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Need to find command for crontab on reboot

Tue Mar 03, 2020 4:31 pm

pcmanbob wrote:
Tue Mar 03, 2020 10:20 am
I still cant understand why your first cron line does not work but the second one does.

what happens if you change the cron line to this

Code: Select all

@reboot /storage/script/Onreboot.sh >> /storage/script/errlog.txt 2>&1
Hi, no error and errlog.txt is empty so, no print of "start" and "end"

Code: Select all

  CGroup: /system.slice/cron.service
           └─296 /sbin/crond -f -S

Apr 11 18:28:37 LibreELEC systemd[1]: Starting Cron daemon...
Apr 11 18:28:37 LibreELEC systemd[1]: Started Cron daemon.

~
~
~
i find an other solution to use the usb2.0 for the DVB tuner to have no error on TVHEADend server on reboot

pcmanbob
Posts: 8342
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Need to find command for crontab on reboot

Wed Mar 04, 2020 9:25 am

I just don't get why cron wont run you cron line, as I use it all the time in my pi projects and how done since the very first version of raspbian ,
its got me stumped now.

But glad you fund another way round your problem.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Beginners”