Jump to content


Photo

Crontab info or a Plugin Enigma2


  • Please log in to reply
72 replies to this topic

#1 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 14 June 2023 - 17:36

hi guys!

 

Is there a plugin to manage Crontab?

 

I want to start a script every 60 minutes but giving the command nothing happens

 

my command:

 

crontab -e  */60 * * * * /usr/script/test5.sh >/tmp/cron.log

 

 

 

root@sf8008:~# crontab -e  */60 * * * * /usr/script/test5.sh >/tmp/cron.log
BusyBox v1.31.0 (2022-09-10 21:29:41 UTC) multi-call binary.

Usage: crontab [-c DIR] [-u USER] [-ler]|[FILE]

        -c      Crontab directory
        -u      User
        -l      List crontab
        -e      Edit crontab
        -r      Delete crontab
        FILE    Replace crontab by FILE ('-': stdin)

 

 

 



Re: Crontab info or a Plugin Enigma2 #2 neo

  • PLi® Contributor
  • 715 posts

+48
Good

Posted 14 June 2023 - 18:13

Is cron itself installed and running?

 

And looking at the correct directory? I know there were some issues with that which are corrected in the current develop. (old images used /etc/cron, standard cron uses /var/spool/cron).



Re: Crontab info or a Plugin Enigma2 #3 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 14 June 2023 - 18:26

yes in /var/spool/cron in OpenPLi 8.3

 

so are there any cron issues with the current image?



Re: Crontab info or a Plugin Enigma2 #4 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 14 June 2023 - 18:33

root@sf8008:~# opkg list | grep cron

busybox-cron - 1.31.0-r0.127 - Tiny versions of many common UNIX utilities in a single small executable
cronie - 1.5.4-r0.0 - Cron daemon for executing programs at set times
cronie-dbg - 1.5.4-r0.0 - Cron daemon for executing programs at set times - Debugging files
cronie-dev - 1.5.4-r0.0 - Cron daemon for executing programs at set times - Development files
cronie-doc - 1.5.4-r0.0 - Cron daemon for executing programs at set times - Documentation files

root@sf8008:~# opkg list-installed | grep cron

busybox-cron - 1.31.0-r0.127
root@sf8008:~#



Re: Crontab info or a Plugin Enigma2 #5 neo

  • PLi® Contributor
  • 715 posts

+48
Good

Posted 14 June 2023 - 19:01

root@sf8008:~# opkg list-installed | grep cron

busybox-cron - 1.31.0-r0.127

 

That's ok.

 

yes in /var/spool/cron in OpenPLi 8.3

 

so are there any cron issues with the current image?

 

It's been to long since I've used a release image. Check

grep ARGS= /etc/init.d/busybox-cron

to see what path is used by cron.


Edited by neo, 14 June 2023 - 19:01.


Re: Crontab info or a Plugin Enigma2 #6 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 14 June 2023 - 19:14

 

root@sf8008:~# opkg list-installed | grep cron

busybox-cron - 1.31.0-r0.127

 

That's ok.

 

yes in /var/spool/cron in OpenPLi 8.3

 

so are there any cron issues with the current image?

 

It's been to long since I've used a release image. Check

grep ARGS= /etc/init.d/busybox-cron

to see what path is used by cron.

 

root@sf8008:~# grep ARGS= /etc/init.d/busybox-cron
ARGS="-c /var/spool/cron/crontabs"



Re: Crontab info or a Plugin Enigma2 #7 neo

  • PLi® Contributor
  • 715 posts

+48
Good

Posted 14 June 2023 - 19:19

That's ok.

 

Now that I think of it, I don't think busybox' crontab supports the "-e" commandline syntax. Just use "crontab -e" and then enter you command in the editor that opens...

 

Also, I wonder if "*/60 * * * *" is accepted, for "once every hour", it is better to use "* */1 * * *"


Edited by neo, 14 June 2023 - 19:21.


Re: Crontab info or a Plugin Enigma2 #8 scriptmelvin †

  • PLi® Contributor
  • 720 posts

+46
Good

Posted 14 June 2023 - 19:52

Or just simply "0 * * * *"


Sorry to inform you this member, my brother, passed away.

Re: Crontab info or a Plugin Enigma2 #9 s3n0

  • Senior Member
  • 672 posts

+62
Good

Posted 14 June 2023 - 20:17

Hi.

 

If you tell the cron service that "here is a file", it understands it as an executable binary. That's why you have to run the shell script through an interpreter. For example like this:

* */1 * * *     /bin/bash /usr/script/test5.sh > /tmp/test5.log

The first value */60 at the beginning is of course an error ! A slash marks every N-th repetition, i.e. "stepping size". You used it for the first value from the left which represents minutes. So you want to repeat the same thing every 60 minutes ? That's nonsense ;-). Simply put the fixed value 0 there. So the result will look like this:
0 * * * *
https://crontab.guru/#0_*_*_*_*

“At minute 0  (whenever the minute hand on the real time clock points to zero).”

 

...but the correct expression is also this:
0 */1 * * *

https://crontab.guru...u/#0_*/1_*_*_* 

“At minute 0 past every hour.”

 

Cron works by checking the clock status every minute... as the match:
minutes hours day month week
If the Cron process finds a match with your time data setting with the real clock, then the command that is listed after this time data is executed.

 

Also, allowed numerical values for hours and minutes are only 0 to 59. Yes, even zero is a number ! Together with the zero number, there are basically 60 variations altogether. For example, if you wanted to run something every 30 minutes, then you would use this:
*/30 * * * *

https://crontab.guru/#*/30_*_*_*_*

 

You should also check if your shell script is working properly. It should contain the hashtag: #!/bin/bash on the very first line, and it should also contain newline codes according to Unix, not according to Windows (you can check this in Notepad++, for example).



Re: Crontab info or a Plugin Enigma2 #10 Pike_Bishop

  • Senior Member
  • 1,140 posts

+74
Good

Posted 14 June 2023 - 20:25

 i make my cronjobs always this way for scripts;

(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/wz_box_cifswithcron_link.sh") | crontab -

or with a script with name cronjob.sh in /etc/init.d;

 

#!/bin/sh

#
# cronjob.sh to make a cronjob with a init script
#
CRON_VERZ=/var/spool/cron/crontabs
CRON_FILE=root
 
. /etc/default/rcS
 
 
if [ ! -e $CRON_VERZ/$CRON_FILE ]; then
(crontab -l 2>/dev/null; echo "0 2,3,4,5 * * 0,1,2,3,4 sh /usr/script/standby.sh") | crontab -
(crontab -l 2>/dev/null; echo "30 2,3,4,5 * * * sh /usr/script/standby.sh") | crontab -
(crontab -l 2>/dev/null; echo -e "0 3,4,5 * * 5,6 sh /usr/script/standby.sh\n") | crontab -
fi
 
 
#if ! grep "ext_hdd_backup1_set_unset_link.sh" $CRON_VERZ/$CRON_FILE ; then
# (crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/ext_hdd_backup1_set_unset_link.sh") | crontab -
#fi
 
 
if ! grep "wz_box_cifswithcron_link.sh" $CRON_VERZ/$CRON_FILE ; then
(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/wz_box_cifswithcron_link.sh") | crontab -
fi
 
if ! grep "wz_box_nfswithcron_link.sh" $CRON_VERZ/$CRON_FILE ; then
(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/wz_box_nfswithcron_link.sh") | crontab -
fi
 
 
(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/hiddenmount.sh") | crontab -
 
 
: exit 0
 

and they works perfect in openpli-8.3

 

so that;

(crontab -l 2>/dev/null; echo "* */1 * * * sh /usr/script/test5.sh >/tmp/cron.log") | crontab -

i think did work for @marcus83

 

 

regards

Pike


Edited by Pike_Bishop, 14 June 2023 - 20:31.

Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: Crontab info or a Plugin Enigma2 #11 s3n0

  • Senior Member
  • 672 posts

+62
Good

Posted 14 June 2023 - 21:44

@marcus83:

 

In addition to the above-mentioned errors that I fixed for you, I also add that I edit the configuration file manually, via FTP connection:

/etc/cron/crontabs/root

 

Then I simply save the file back via FTP and restart the CRON service via the "init.d" shell script:

- for OpenATV: /etc/init.d/crond {start|stop|restart}

- for OpenPLi:  /etc/init.d/busybox-cron {start|stop|restart}



Re: Crontab info or a Plugin Enigma2 #12 neo

  • PLi® Contributor
  • 715 posts

+48
Good

Posted 14 June 2023 - 22:56

( assuming you haven't replaced busybox-cron by crond ;) )



Re: Crontab info or a Plugin Enigma2 #13 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 15 June 2023 - 03:24

 i make my cronjobs always this way for scripts;

(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/wz_box_cifswithcron_link.sh") | crontab -

or with a script with name cronjob.sh in /etc/init.d;

 

#!/bin/sh

#
# cronjob.sh to make a cronjob with a init script
#
CRON_VERZ=/var/spool/cron/crontabs
CRON_FILE=root
 
. /etc/default/rcS
 
 
if [ ! -e $CRON_VERZ/$CRON_FILE ]; then
(crontab -l 2>/dev/null; echo "0 2,3,4,5 * * 0,1,2,3,4 sh /usr/script/standby.sh") | crontab -
(crontab -l 2>/dev/null; echo "30 2,3,4,5 * * * sh /usr/script/standby.sh") | crontab -
(crontab -l 2>/dev/null; echo -e "0 3,4,5 * * 5,6 sh /usr/script/standby.sh\n") | crontab -
fi
 
 
#if ! grep "ext_hdd_backup1_set_unset_link.sh" $CRON_VERZ/$CRON_FILE ; then
# (crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/ext_hdd_backup1_set_unset_link.sh") | crontab -
#fi
 
 
if ! grep "wz_box_cifswithcron_link.sh" $CRON_VERZ/$CRON_FILE ; then
(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/wz_box_cifswithcron_link.sh") | crontab -
fi
 
if ! grep "wz_box_nfswithcron_link.sh" $CRON_VERZ/$CRON_FILE ; then
(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/wz_box_nfswithcron_link.sh") | crontab -
fi
 
 
(crontab -l 2>/dev/null; echo "* * * * * sh /usr/script/hiddenmount.sh") | crontab -
 
 
: exit 0
 

and they works perfect in openpli-8.3

 

so that;

(crontab -l 2>/dev/null; echo "* */1 * * * sh /usr/script/test5.sh >/tmp/cron.log") | crontab -

i think did work for @marcus83

 

 

regards

Pike

hi!

 

with this command works! thx!

 

(crontab -l 2>/dev/null; echo "* */1 * * * sh /usr/script/test5.sh >/tmp/cron.log") | crontab -

 

but with * */1 * * * does the script start every hour?

 

Can you also tell me the command to remove it?



Re: Crontab info or a Plugin Enigma2 #14 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 15 June 2023 - 05:34

Pike_Bishop

 

I understood how to modify and eliminate, I just want to know how long  * */1 * * *  does it start?


Edited by marcus83, 15 June 2023 - 05:42.


Re: Crontab info or a Plugin Enigma2 #15 Tech

  • Forum Moderator
    PLi® Core member
  • 14,897 posts

+486
Excellent

Posted 15 June 2023 - 05:58



Pike_Bishop

 

I understood how to modify and eliminate, I just want to know how long  * */1 * * *  does it start?

I thought that was explained overhere


Aan de rand van de afgrond is een stap voorwaarts niet altijd vooruitgang....

On the edge of the abyss, a step forward is not always progress....

Hardware: 2x Daily used Vu+ Ultimo 4K - Vu+ Duo 4K SE and a lot more.... - VisioSat BiBigsat - Jultec Unicable Multiswitch 4 positions: 19.2/23.5/28.2 East - Diseqc motorized flatdish antenna

Software : HomeBuild OpenPLi Develop and Scarthgap builds, local cards driven by OsCam

Press the Geplaatste afbeelding button on the buttom right of this message ;)

Have you tried our wiki yet? Many answers can be found in our OpenPLi wiki


Re: Crontab info or a Plugin Enigma2 #16 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 15 June 2023 - 06:16

 



Pike_Bishop

 

I understood how to modify and eliminate, I just want to know how long  * */1 * * *  does it start?

I thought that was explained overhere

 

thx!



Re: Crontab info or a Plugin Enigma2 #17 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 15 June 2023 - 06:53

Cron also works when the decoder is in standby?



Re: Crontab info or a Plugin Enigma2 #18 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 15 June 2023 - 09:46

Cron also works when the decoder is in standby?

 

[auto answer]

It works perfectly on standby



Re: Crontab info or a Plugin Enigma2 #19 s3n0

  • Senior Member
  • 672 posts

+62
Good

Posted 15 June 2023 - 09:46

@marcus83

 

Why don't you read what I write ?

 

Please click on the link (I mean "crontab.guru" webpage), which I sent you before !!! There it is explained in human language, when exactly the specified time-entry will be started, in the CRON configuration line :). This website is designed for exactly this purpose, or primarily for this purpose:

https://crontab.guru/


Edited by s3n0, 15 June 2023 - 09:48.


Re: Crontab info or a Plugin Enigma2 #20 marcus83

  • Senior Member
  • 106 posts

0
Neutral

Posted 15 June 2023 - 10:33

@marcus83

 

Why don't you read what I write ?

 

Please click on the link (I mean "crontab.guru" webpage), which I sent you before !!! There it is explained in human language, when exactly the specified time-entry will be started, in the CRON configuration line :). This website is designed for exactly this purpose, or primarily for this purpose:

https://crontab.guru/

yes I have already thanked @Tech for this...




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users