SOLVED cron won't work

  • I have enabled cron in LibreELEC settings. My system time is correct.

    I want a script to run ever night at 1 A.M.

    I can run the script manually by typing "/storage/update.sh"

    I had the program running under Raspbian cron.

    My root crontab:
    00 1 * * * /storage/update.sh > /dev/null


    I don't need cron to email a report, the app has it's own log.

    Edited once, last by donbrew (October 20, 2016 at 3:22 PM).

  • Okay, so why won't this run?

    54 16 * * * /storage/helloworld.sh


    helloworld runs from the PuTTY CLI, it is chmod 755, it is the standard bash test script:
    #!/bin/bash
    echo Hello World!!!!

    Edited once, last by donbrew (September 30, 2016 at 10:13 PM).

  • worked for me, even with 00

    Code
    LibreELEC:~ # crontab -l
    00 15 * * * /storage/test.sh > /storage/test.output
    Code
    LibreELEC:~ # systemctl status cron
    Sep 30 15:00:00 LibreELEC crond[2473]: USER root pid 3670 cmd /storage/test.sh > /storage/test.output
    Code
    LibreELEC:~ # cat /storage/test.sh
    #!/bin/sh
    echo "Hello World!!!!"
    Code
    LibreELEC:~ # ls -l /storage/test.sh
    -rwxr-xr-x    1 root     root            34 Sep 30 14:58 test.sh
    Code
    LibreELEC:~ # cat /storage/test.output
    Hello World!!!!
  • Tried adding the root name, negative result.

    I ran all the code that Irusak did; h'mmm there was out put to the file, but.. here is what I got with the systemctl status cron command:

    Seems to say cron is disabled by vendor. I did tick enable in settings. This was done on a completely virgin install of milhouse 929

  • I have no idea why it says Sept 29! I just installed it a few minutes ago.

    I tried first on a fresh 7.0.2 install then upgraded to milhouse 929. cron did not work on either.

    As of this moment update.sh is irrelevant because helloworld.sh will not run unless I run "systemctl status cron" first; then it does run.

    This is the contents of one of the update.sh that did run in Rasbian, but not in LibreELEC (adjusted for different file structure).

    Bash
    #!/bin/bash
    cd /storage/wg++
    
    
     mono WebGrab+Plus.exe  "$(pwd)"


    If I am reading the output correctly, I need to know how to enable cron.

    And it does run from the CLI.

    Edited once, last by donbrew (October 1, 2016 at 5:22 PM).

  • Works for me. Created shell file, make it executable, add cron entry with crontab -e and it was fired at a time I requested.
    Didn't enabled anything - it just works.

    update.sh is very much relevant. But seems you know what you are doing...

  • I meant that I have moved on from that script to a much simpler one that was tested by someone else and myself. (I have since edited my post, we were typing at the same time).

    Now I have tested on 3 different installs of 2 different versions of LibreELEC. cron does not work UNLESS I run "systemctl status cron" first, then only once. testing in progress for "systemctl start cron" and disabling cron in settings.

    Does not work at all when disabled in settings.

    Edited once, last by donbrew (October 1, 2016 at 6:11 PM).

  • donbrew
    > I have no idea why it says Sept 29!
    Almost certainly because the time hasn't yet been sync'd :-} as per other threads...
    That date is the kernel build date of #929.
    So cron is starting before the clock is right - confirmed by the message about time disparity.


  • How did you create crontab file? With crontab command?

    yes crontab -e, and also with notepad++.
    [hr]
    The time zone was set and pool.ntp.org was set and on a wired network for 9 days on milhouse 920. I would think something would sync.

    What seems to have worked: I ran "systemctl start cron" and rebooted, with cron enabled in settings.

    This has been going on for weeks, I started this thread after playing on my own for a week or 2.

    Is there a way to force cron to wait for the time to set after a reboot?

    Thank everybody, it seems fixed for the time being.

    Edited once, last by donbrew (October 1, 2016 at 7:30 PM).

  • donbrew
    > Is there a way to force cron to wait for the time to set after a reboot?
    This is basically the same question I have been asking wrt mounting shares & time syncronisation :-}
    I think time-sync.target *ought* to be the answer, but systemd in LE doesn't seem to use/invoke it.

    PS If you add 'debugging' to cmdline.txt you get a raft of messages about connman and whatnot in the journal. I must confess I haven't found them very helpful :-{

    Edited once, last by agb (October 1, 2016 at 8:05 PM).

  • The weird thing is system time was right. It was Cron had the wrong time.

    I had a similar problem in the way back with NPVR not recording, that one was because the PC BIOS clock somehow reset itself to the wrong time, but the NPVR guide had the correct time. I never figured out how that happened and the same PC has been running without any problems for several years since.


  • The weird thing is system time was right. It was Cron had the wrong time.

    I had a similar problem in the way back with NPVR not recording, that one was because the PC BIOS clock somehow reset itself to the wrong time, but the NPVR guide had the correct time. I never figured out how that happened and the same PC has been running without any problems for several years since.

    donbrew
    Here's the tail of my journal with #1001.

    Oct 01 00:44:39 LibreELEC systemd[1]: Reached target Network is Online.
    Oct 01 00:44:39 LibreELEC connmand[407]: ntp: time slew +116391.088628 s
    Oct 02 09:04:30 LibreELEC systemd[1]: Starting Kodi Media Center...
    Oct 02 09:04:30 LibreELEC systemd[1]: Time has been changed
    Oct 02 09:04:30 LibreELEC kodi-config[689]: chmod: /storage/.kodi/addons/*/bin/*
    : No such file or directory
    Oct 02 09:04:30 LibreELEC systemd[1]: Started Kodi Media Center.

    Note the initial timestamps - kernel build time.
    On this occasion, 'Starting Kodi Media Center...' occurs after the clock is corrected.
    On other occasions it occurs before, there can be a variance of a few seconds.
    When it occurs before, my network mounts fail, because the Windows server
    doesn't like the clock difference.