Cron - it's not working

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • Cron - it's not working

      Hi Guys,

      I have the new 3.3.2 image installed in my dm800se, I have installed the cron via telnet and added the following:
      (all 755)
      /usr/script/reboot.sh

      #!/bin/sh
      wget -q -O - root:password@192.168.12.3/web/powerstate?newstate=2

      I've tried this as well :

      /sbin/init 5
      /bin/sleep 5
      /sbin/reboot


      /cron/tabs/root

      0 4 * * * /usr/script/reboot.sh


      when I do crontab -l

      the cron is listed.

      But doesn't reboot!
      I've also tried to start the cron manually but still doesn't work.

      Any idea?

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von eXaLtY ()

    • RE: Cron - it's not working

      Does your script work if started manually? Is the file-attribute of your script 755? Did you use a linux/unix editor to create?

      There was/is a bug in the DMM Web-Interface too. Some commands like reboot, restart didn't work when executed from shell or by script. I'm not shure that this bug is already fixed in Newnigma2 3.3.2 or if the DMM bug-fix for the Web-Interface was issued after NN2 v3.3.2 release.

      Try to execute the command twice in your script:

      Shell-Script

      1. #!/bin/sh
      2. wget -q -O - http://root:password@192.168.12.3/web/powerstate?newstate=2
      3. wget -q -O - http://root:password@192.168.12.3/web/powerstate?newstate=2


      this "fix" worked in one of my own shellscripts. In current images based on OE2.0 this bug is definitely removed
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      ¯\_(ツ)_/¯

      Quellcode

      1. root@dm920:~$ mount | grep "/ "
      2. /dev/mmcblk1p1 on / type ext4 (rw,relatime,data=ordered)
      3. root@dm920:~$

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Fred Bogus Trumper ()

    • Hi,

      Thanks for replying.

      The chmod are in deed 755 and I've used the DCC editor.

      Is not the 3.3.2 OE2.0 based?
      How can I see that?
      And where are the OE2.0 images from newnigma?

      I will try today the command twice.
    • do you use the plugin "cron" from the online feed? the dmm busybox-cron in OE1.6 is buggy too:

      try this to test cron

      opkg update
      opkg install cron
      crontab -e

      Quellcode

      1. */1 * * * * /bin/echo "cron test ok - $(date)" >> /tmp/crontest.log


      save the new crontab and restart cron

      /etc/init.d/cron stop
      /etc/init.d/cron start

      the log should look like this after a few minutes:

      Quellcode

      1. root@dm800se:~# cat /tmp/crontest.log
      2. cron test ok - Wed Aug 1 18:41:00 CEST 2012
      3. cron test ok - Wed Aug 1 18:42:00 CEST 2012
      4. cron test ok - Wed Aug 1 18:43:00 CEST 2012
      5. root@dm800se:~#


      and you can be shure that cron works correctly, next step is your script
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      ¯\_(ツ)_/¯

      Quellcode

      1. root@dm920:~$ mount | grep "/ "
      2. /dev/mmcblk1p1 on / type ext4 (rw,relatime,data=ordered)
      3. root@dm920:~$

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Fred Bogus Trumper ()

    • Thanks for the reply, I've followed your instructions and still no log file in TMP folder.

      in /cron/log I HAVE:

      root (08/01-19:38:04-27680) BEGIN EDIT (root)
      CRON (08/01-19:39:47-27962) STARTUP (fork ok)
    • cron does his job in Newnigma2 v3.3.2, your log tells you

      Quellcode

      1. CRON (08/01-19:39:47-27962) STARTUP (fork ok)


      try this to check cron is running
      root@dm800se:~# ps | grep -v grep | grep cron
      2148 root 2044 S /usr/sbin/cron
      root@dm800se:~#


      my log in Newnigma2 v.3.3.2

      Quellcode

      1. root@dm800se:~# cat /cron/log
      2. CRON (08/02-00:07:14-2148) STARTUP (fork ok)
      3. root (08/02-00:08:00-2279) CMD (/usr/script/cronmessage.sh)
      4. root (08/02-00:08:00-2281) CMD (/bin/echo "cron test ok - $(date)" >> /tmp/crontest.log)
      5. root (08/02-00:09:00-2480) CMD (/usr/script/cronmessage.sh)
      6. root (08/02-00:09:00-2482) CMD (/bin/echo "cron test ok - $(date)" >> /tmp/crontest.log)
      7. root (08/02-00:10:00-2672) CMD (/usr/script/cronmessage.sh)
      8. root (08/02-00:10:00-2674) CMD (/bin/echo "cron test ok - $(date)" >> /tmp/crontest.log)
      9. root (08/02-00:11:00-2859) CMD (/usr/script/cronmessage.sh)
      10. root (08/02-00:11:00-2860) CMD (/bin/echo "cron test ok - $(date)" >> /tmp/crontest.log)
      11. root (08/02-00:12:00-3064) CMD (/usr/script/cronmessage.sh)
      12. root (08/02-00:12:00-3065) CMD (/bin/echo "cron test ok - $(date)" >> /tmp/crontest.log)
      13. root@dm800se:~#
      Alles anzeigen


      there must be a mistake in your script(s). Did you install v3.3.2 in Flasch or do u use tools like Barry Allen, Dumbo, Rambo or things like this to boot from USB or to expand your Flash?
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      ¯\_(ツ)_/¯

      Quellcode

      1. root@dm920:~$ mount | grep "/ "
      2. /dev/mmcblk1p1 on / type ext4 (rw,relatime,data=ordered)
      3. root@dm920:~$

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Fred Bogus Trumper ()

    • Thanks for your reply!

      I've checked and cron log as this info:

      CRON (08/02-06:55:45-649) STARTUP (fork ok)
      root (08/02-19:31:06-28757) BEGIN EDIT (root)
      root (08/02-19:37:46-28757) REPLACE (root)
      root (08/02-19:37:46-28757) END EDIT (root)
      root (08/02-19:38:00-649) RELOAD (tabs/root)
      CRON (08/02-19:39:42-30347) STARTUP (fork ok)
      root (08/03-04:00:00-16682) CMD (/usr/script/reboot.sh)
      CRON (08/03-05:50:37-651) STARTUP (fork ok)

      So it means that cron is working fine....

      I've installed in the flash directly.

      So maybe something with the script?

      #!/bin/sh
      wget -q -O - root:password@192.168.23.13/web/powerstate?newstate=2
      wget -q -O - root:password@192.168.23.13/web/powerstate?newstate=2

      I've made a duplicate like you told me but still doesn't work.
    • I testetd the reboot executed by cron in NN2 v3.3.2 and it works - the Web-IF bug is already fixed and only one command is necessary

      try this on commandline to create the (new) script
      copy & paste - 127.0.0.1 as localhost instead of IP of the Box works too

      Quellcode

      1. echo "#!/bin/sh" > /usr/script/reboot.sh
      2. echo "wget -q -O- http://root:password@127.0.0.1/web/powerstate?newstate=2" >> /usr/script/reboot.sh
      3. chmod 755 /usr/script/reboot.sh
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      ¯\_(ツ)_/¯

      Quellcode

      1. root@dm920:~$ mount | grep "/ "
      2. /dev/mmcblk1p1 on / type ext4 (rw,relatime,data=ordered)
      3. root@dm920:~$

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Fred Bogus Trumper ()

    • Mate,

      It's Working!

      CRON (08/04-00:34:33-651) STARTUP (fork ok)
      root (08/04-00:54:26-3313) LIST (root)
      CRON (08/04-01:06:38-657) STARTUP (fork ok)
      CRON (08/04-01:09:29-652) STARTUP (fork ok)
      root (08/04-04:00:00-23829) CMD (/usr/script/reboot.sh)
      CRON (08/04-04:00:51-653) STARTUP (fork ok)
      CRON (08/04-06:09:32-650) STARTUP (fork ok)

      I wake up and I saw up time since 4 AM!

      Many thanks!!!!
      :D

      I only saw this WARNING: invalid client tcp_conn_close()
      2012/08/04 06:03:13 2B702528 c cards disconnected from 127.0.0.1

      In Oscam after the reboot couldn't pick up the user from CCcam.

      Do you think that might be related??
      Is there any other way to reboot without using the web interface command?


      Thanks dude, really nice of you! :D
    • Original von eXaLtY
      Is there any other way to reboot without using the web interface command?


      reboot
      or better, I think
      shutdown -r now

      and u don't need a script for this, just use a crontab

      0 4 * * * /sbin/shutdown -r now


      if u want the reboot in cause of problem with your emu: there is an option in Newnigma2 Services for daily emu restart

      or executed wiht cron

      0 4 * * * /usr/bin/camdctrl restart

      this restarts the running emu
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      ¯\_(ツ)_/¯

      Quellcode

      1. root@dm920:~$ mount | grep "/ "
      2. /dev/mmcblk1p1 on / type ext4 (rw,relatime,data=ordered)
      3. root@dm920:~$

      Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von Fred Bogus Trumper ()

    • Dude,

      I don't know if someone already told you? But You Rock my Friend!!!! :D

      Does it work as well in OE2.0 images?

      Do you have a script for checking if oscam is not running then restart camd?

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von eXaLtY ()

    • oscamcheck.sh

      Shell-Script

      1. #!/bin/sh
      2. if ps -a |grep -v grep |grep -c oscam_1.20 >/dev/null
      3. then
      4. echo "OScam ok"
      5. else
      6. /usr/bin/oscam_1.20 -b
      7. fi


      cron

      Quellcode

      1. */2 * * * * /usr/script/oscamcheck.sh


      you may have to change oscam version in the script, in this example v. 1.20

      i guess a well configured oscam doesn't need something like this...
    • Originally posted by EverythingZen
      oscamcheck.sh

      Shell-Script

      1. #!/bin/sh
      2. if ps -a |grep -v grep |grep -c oscam_1.20 >/dev/null
      3. then
      4. echo "OScam ok"
      5. else
      6. /usr/bin/oscam_1.20 -b
      7. fi


      cron

      Quellcode

      1. */2 * * * * /usr/script/oscamcheck.sh


      you may have to change oscam version in the script, in this example v. 1.20

      i guess a well configured oscam doesn't need something like this...


      Would this also work?

      #!/bin/sh
      if ps -a |grep -v grep |grep -c oscam >/dev/null
      then
      echo "OScam ok"
      else
      /usr/bin/camdctrl restart
      fi


      (my bin is called oscam)
      -----------------------------------------------------------
      This cron checks every 2 minutes?
      cron

      Quellcode

      1. */2 * * * * /usr/script/oscamcheck.sh
    • should work, yes.
      and script is called every 2 minutes in the example.
      if oscam emu is called oscam you have to substitude it in the sh file.

      the best way to check if it's working is to stop oscam and look if it's started 2 minutes later.

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von EverythingZen ()

    • It's working! Thanks Dude.

      Before I've made like this:

      #!/bin/sh
      while [ 1 ]
      do
      pidof oscam_1.00 >/dev/null
      if [ $? -eq 0 ] ; then
      echo "oscam_1.00 is running"
      else
      date=`date`
      echo "Restarting oscam_1.00 : $date" >> /var/log/oscam_1.00.check
      /var/bin/oscam &
      if [ $? -eq 0 ] ; then
      echo "oscam_1.00 is ok!"
      else
      echo "hm, didn't work. Try doing it manually"
      fi
      fi
      sleep 20
      done

      now I've just use your code and it works!

      How can I delete the log file before reaches an hudge amount of data?
      I've tried to deleted manually but afterwords I doesn't create any more the log file.
      The only solution was stop cron and started again, then a new log file was created in \cron\log


      Maybe it's good to stick this Topic. It may help a lot of people!
    • I think, there will be no problem with the amount of data. On my box there is a logfile in /tmp with more than 5000 lines and about 180kb - /tmp used is used 4% ...

      an endless loop is not the best solution, because it can brake - or u run a watchdog for the watchdog :D
      there are other solutions than the endless loop to check e.g every 20 seconds

      One easy way for "autoclean" the logfiles:
      If a defined number of lines (MAXLOGLINES=number) in the logfile is reached, move logfile to logfile.old. Then a new logfile will be created on next run. This solution creates only two files with max. 2 x $MAXLOGLINES lines

      2nd way:
      you overwirte /tmp/tmp/oscam_1.00.status on each run with the result of the last check and log only all restarts in /tmp/oscam_1.00.restarts. This will create less data. in the .status file u can see the last result and when the last check was done (wd still running?)

      The numer of lines in /tmp/oscam_1.00.results could be cleaned on the same way as shown - if wanted

      example (if all comment lines (# in front) are deleted, its very short - but do not delete the # in first line!)
      /usr/script/oscam_watchdog.sh

      Shell-Script

      1. #!/bin/sh
      2. # global variables
      3. MAXLOGLINES=100
      4. LOGFILE=/tmp/oscam_1.00.check
      5. ### get time
      6. # function to get the correct system time in an indivudual format when called - output: yyyy-mm-dd@hh:mm:ss
      7. now () {
      8. date +%Y-%m-%d@%H:%M:%S
      9. }
      10. ### logfile check
      11. # function: if number of lines in logfile >= $MAXLOGLINES then move logfile
      12. logfile_check () {
      13. if [ $(wc -l $LOGFILE | awk '{print $1}') -ge $MAXLOGLINES ] ; then
      14. mv -f $LOGFILE $LOGFILE.old
      15. echo "$(now) - last $MAXLOGLINES lines of $LOGFILE moved to $LOGFILE.old" > $LOGFILE
      16. fi
      17. }
      18. # if logfile exists, check number of lines with above function - if not: skip
      19. [ -e $LOGFILE ] && logfile_check
      20. ### oscam check
      21. # if result of "ps aux ...." = 0, oscam ist NOT running, else running
      22. if [ $(ps aux | grep -v grep | grep -c "/usr/bin/oscam") = 0 ] ; then
      23. echo "$(now) - oscam not running - restarting oscam_1.00" >> $LOGFILE
      24. # alternative: write status in both files
      25. # echo "$(now) - oscam not running - restarting oscam_1.00" >> /tmp/oscam_1.00.restarts
      26. # echo "$(now) - oscam not running - restarting oscam_1.00" > /tmp/oscam_1.00.status
      27. /usr/bin/oscam &
      28. # may be better, because all oscam /tmp files created on start from NN2 start/stop script will cleaned/deleted:
      29. # /usr/script/oscamscriptname.emu restart
      30. # or 'camdctrl restart' if oscam only is used
      31. else
      32. echo "$(now) - oscam_1.00 is running ">> $LOGFILE
      33. # alternative
      34. # echo "$(now) - oscam_1.00 is running " > /tmp/oscam_1.00.status
      35. fi
      36. exit
      Alles anzeigen


      executed with cron every minute should be ok - but u can execute the script twice or tripple every minute with cron too:

      crontab to execute every minute
      */1 * * * * /usr/script/oscam_watchdog.sh

      executed twice within a minute (every 30 seconds)
      */1 * * * * /usr/script/oscam_watchdog.sh && sleep 30 && /usr/script/oscam_watchdog.sh

      executed three times within a minute (every 20 seconds)
      */1 * * * * /usr/script/oscam_watchdog.sh && sleep 20 && /usr/script/oscam_watchdog.sh && sleep 20 && /usr/script/oscam_watchdog.sh


      A third possibility beside cron and endless loop is a self-executing script which restarts itself after sleeping a defined time. But it is a little bit more comlicated to run correctly, in cause u have to prevent to start the script a second time when allready running

      I think that the cron solution is the best and easiest way

      have fun with testing & scripting :D
      Gruß Fred

      Die Dreambox ist tot, es lebe die Dreambox

      ¯\_(ツ)_/¯

      Quellcode

      1. root@dm920:~$ mount | grep "/ "
      2. /dev/mmcblk1p1 on / type ext4 (rw,relatime,data=ordered)
      3. root@dm920:~$

      Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von Fred Bogus Trumper ()

    • Once more you Rock dude!!! :D

      I've noticed that the log file from cron gets bigger and bigger, this one needs to be flushed.....

      I've used the other script mentioned and I saw that oscam is restarting even when was running.... this lead to the situation of not getting my cards to read at all and the proxies not able to reconnect due to an existing connection.

      Any idea how to fix this?

      Perhaps using your script will fix completely this situation, I will try tomorrow.

      Another point is how to set a date by script when the dreambox is not connected to the sat cable?

      I have this that it's currently working but maybe you guys know another way?

      all_info=`wget -q -O /tmp/all.info islaremota.com/date.php?all=1; cat /tmp/all.info`
      echo `date $all_info`

      If the website doesn't respond I stay with no date and my box restarts at every 4 hours... lol

      thks you all.