uwcron: Cron for the fun_plug

Since quite a while i was often asked if there is a possibility to store entries into crontab permanently on NAS devices with fun_plug. That is not that easy as the devices reset their crontab to the default one on every reboot. Therefore you need to add the entries every time the device reboots. I have now developed a script which automates that for your convenience.

Werbung


The package with the name “uwcron” is available via my repository:

slacker -UaA uli:uwcron
[[ -f /ffp/start/uwcron.sh.new ]] && mv /ffp/start/uwcron.sh.new /ffp/start/uwcron.sh

As soon as this is installed, you can start with the configuration. The configuration files should be created in /ffp/etc/cron.d/. These could look like this:

*/5  * * * * /tmp/uwfancontrol.sh

When all configuration files are created, the service can be started. This works as with all other services:

chmod a+x /ffp/start/uwcron.sh
/ffp/start/uwcron.sh start

Now you should see your entries in crontab:

crontab -l

If the device is rebootet, all entries from these files in /ffp/etc/cron.d/ would be copied into crontab. if you made a change to a file, you could also just restart the service instead of the complete NAS:

/ffp/start/uwcron.sh restart

Questions?

63 thoughts on “uwcron: Cron for the fun_plug”

  1. Thank you.

    Sadly the first instruction is not clear: are we supposed to run ‘slacker -UaA… ‘ and then enter the next line “[[ -f /ffp… ” ?

    Are both one command or 2?

    Using ‘slacker -UaA… ‘ seems to install fine.

    Please advise.

    1. Hi Oni,

      these are two commands, you need to execute them both. If this is the first installation, you could leave it aside, but just to be sure, do them both.

      Best Regards,
      Uli

  2. After the install of uwcron on the DNS320, every command for crontab results in the following error message: “crontab: symbol ‘_res’: can’t resolve symbol”

    I created in /ffp/etc/cron.d/ the file ‘rsnapshot’ with standard cron instructions.

      1. That did it 😉 Ok, works perfectly with full path.

        Did work without full path before the installation, though…

  3. Hi Uli,
    I installed fun_plug and uwfancontrol on DNS-320L but it seems that some commands (temperature and fanspeed) are missing.

    /ffp/bin/which: no fancontrol in (/usr/bin:/bin:/usr/sbin:/sbin)
    /ffp/var/opt/uwfancontrol/uwfancontrol.sh: line 51: /usr/sbin/temperature: not found
    /ffp/var/opt/uwfancontrol/uwfancontrol.sh: line 53: /usr/sbin/temperature: not found
    sh: 40: unknown operand
    sh: 32: unknown operand
    sh: 60: unknown operand
    /ffp/var/opt/uwfancontrol/uwfancontrol.sh: line 74: /usr/sbin/fanspeed: not found

    I didn’t find those commands in any downloadable package, am I missing something or there is a compatibility issue between uwfancontrol and 320L (firmware 1.02b7)?

    Thanks,
    Andrea

  4. running
    slacker -UaA command i get the following error, and dont know what to do to fix it.

    cheers

    Updating package lists...
    fetch: rsync -q 'rsync://ffp.inreto.de/ffp/0.7/arm/packages/CHECKSUMS.md5' '/ffp/funpkg/cache/s'
     
    cmp: symbol '_res': can't resolve symbol
    Aborted
  5. Hello,
    I am running an old version of ffp (probably 0.5).
    How could I get this installed via funpkg ? Where could I get uwcron tar.gz file?

    Thanks!

    1. The command is “mail” and can be configured on the commandline. Please use the full path to the binary to ensure a working crontab.

      Best Regards,
      Uli

  6. Hi !
    You made my day, I crashed my DNS 325 yesterday by trying to modify template config XML file…

    Thank you for your script

  7. Hi Uli,

    I’ve tried editing crontab -e using nano, and i received the following error:

    Received SIGHUP or SIGTERM

    How can I resolve this to edit my crontab?

    Thanks.

    1. dns320 with ffp 0.7
      uwcron installed
      it’s work fine for some hours…
      and after crontab -l report me that will be reset to initial state…
      /var/spool/cron/crontab/root.txt

      i haven’t found which routine will be lauched any 6/8 hours…

      any helps?

      tnks in adv…

  8. Is it possible to run python scripts from cron?

    things like
    * * * * * python /mnt/HD_a2/frame/script.py

    won’t work

    1. I have the same issue on my DNS320. It works after install and manual starting of uwcron.sh but after some time it gets reverted.

    2. Also having the same issue. It seems to have only recently started. And it’s not related to uwcron because I’m not running it. i wrote my own crontab insertion script.

      Thanks.

    3. @Jan – this still happens in 2016 , even though
      !#/ffp/bin/sh is added on the top of each cron instruction file

  9. Hi, I was node ring if someone could point me in the Rightdirection.

    Issue, the uwcron does not seem to run my custom scripts anymore. Simple script that echos and writes content to file as test. I was working when I installed funpkug, with uli’s uwcron to my d link 320L nas drive on volume 1. The uwcron config file is placed in /ffp/etc/cron.d/crontab.1112 with permission set to root and 777. The script is located in the roots’s home directory. I also restarted the /ffp/start/uwcron.

    The configuration worked will I modified the /ffp/etc/cron.d/crontab.1112 file for another script. It did not work and revered back to the original entry which did not help.

    Entry used

    */60 * * * * /ffp/home/root/scripts/test.sh

    Pointers?

    Oh the system cron devices are working correctly. I get daily status emails which shows the system cron is functional.

    Thanks

  10. I also find the crontab -l to be reset periodically.

    The problem seems to be that my script that was called from crontab started with #!/bin/sh

    Starting the script with #!/ffp/bin/sh
    seems to solve the problem.

    Why? Try typing /bin/sh in a terminal on the DNS320 and you are in the ash shell, waiting for input. Cron can’t supply this input. I am not sure why the crontab is reset after this, but the time matched perfectly with when my script is running.

      1. I am having this problem as well. My script does start with #!/ffp/bin/sh and still, the cron table gets reset periodically.

  11. My mistake, issue was I was using a call script and the system did not know what directory I was in which mean t the script I wanted to all could not be found. Once full path filled the script executed correctly.

    Terry

  12. I was wrong: still get reset of crontab to default. The crontab reset at 06:50:01, again. Always the same time.

    I know this (within 10 minutes) because I added this row to the modified crontab in /ffp/etc/cron.d/cronjobs

    */10 * * * * /ffp/bin/date > /mnt/HD_a2/USERS/jan/Dokument/test2
    1. Any luck in resolving this? I’m still having the same issue with crontab resetting to default.

      Thanks.

  13. I can not start the service.

    The message is

    root@EDDIE:~# /ffp/start/uwcron.sh start
    cat: write error: No space left on device
    root@EDDIE:~#

    What can i do to fix that? I have a lot space from my hard disk

    1. Looks like something has filled up your internal flash – reboot and try again. If the problem persists, you need to find the culprit which fills that – that will be enerving 😉

      Best Regards,
      Uli

    1. “As soon as this is installed, you can start with the configuration. The configuration files should be created in /ffp/etc/cron.d/. These could look like this:”

      What are these configuration files? what format shall they be in?

  14. I have gotten cron to work, end the instruction is visible when i write crontab -l

    But I cant get it to launch a java-application.
    When I run the shellscript it works fine.
    But cron doesnt seem to run it.

    The script looks like this

    export PATH=/ffp/sbin:/ffp/bin:$PATH
    export JAVA_HOME=/ffp/opt/java/jre/bin#
     
    java -jar /mnt/HD/HD_a2/Nigge/SensorReader/SensorReader.jar

    My guess is that cron cant fint the path to java, thats why I have added that path…

    But still no luck, any tips?

  15. Hi,

    As Jan and Sidneydream I have had the same issue (crontab was reseted periodically).

    A way to solve this problem, without using uwcron has been to :
    – create a file with the original tasks to be croned in /mnt/HD/HD_a2/ffp/home/root
    crontab -l >> crontab.config
    – then to add the new tasks I wanted to be periodiccaly launched
    – then create a new file, let say ‘initcrontab.sh’ in /ffp/start and add in it the following line
    crontab /mnt/HD/HD_a2/ffp/home/root/crontab.config
    -and finally make it executable for all
    chmod 777/ffp/start/initcrontab.sh

    After rebooting it works.

        1. @Sylvain , @Jan – and yes , looks like it keeps getting reset every 6-8 hours or so after reboot

          So now i am adding a line ( every 30 mins ) in the cron to rerun “crontab filname” to repopulate the cron. Lets see what happens. Long shot but lets see.

          The last thing to try would be to edit the config.xml file as mentioned here

          1. Hmmmm …jumping straight to the config.xml method ..better chance of succeeding I reason.

        2. After a few days, the only method that lasted was to have another cronned script running every 30m to run crontab with the custom scripts;

          Create this script in /ffp/start – call it checkcrontab.sh and make it executable.

          #!/ffp/bin/sh
           
          # we get this to be re-executed every half hour in an 
          # eternal whileloop
          # and keep in /ffp/start
          # additional_crontab_entries.conf contains the custom 
          # scripts to be executed ( in cron format ) along with the 
          # original cron scripts of the NAS box
           
          while true
          do
            crontab  /ffp/home/root/additional_crontab_entries.conf
            sleep 30m
          done
  16. I’m not sure if anyone else is having this issue but I haven’t seen it be published anywhere.

    I’ve followed all of the steps (which have been well written above). When I try crontab -l my commands appear and I do not see any error messages.

    However, the commands don’t seem to execute at all. They are not lost, as when I check crontab -l again they are still in there.

    Basically, all I have in the script is

    * * * * * /mnt/HD/HD_a2/ffp/sbin/*program*

    And another line to kill the pid after several more hours.

    I’ve tried a simpler script just with an echo every minute but nothing appears in the terminal.

    If it makes any difference, I’m using FDP 0.7 and a dlink 320 (not l).

    Any thoughts?

  17. Has it been removed?

    root@NAS:~# slacker -UaA uli:uwcron
    Updating package lists…
    fetch: rsync -q ‘rsync://ffp.inreto.de/ffp/0.7/arm/packages/CHECKSUMS.md5’ ‘/ffp/funpkg/cache/s’
    No packages found (status Iiu, pattern (^uli:.*uwcron))
    root@NAS:~#

  18. Hi, I am trying to run a command line using UWCRON, after I run the command crontab -l the line are apearing like this

    * * * * * /bin/dsrv-mon.sh > /dev/null 2>&1
    17 */2 * * *...
    "#!/ffp/bin/sh
    */5 * * * * /ffp/start/b. sh### END: 
    Definition from a.sh"

    the files are stored in ffp/start/b.sh and /ffp/etc/cron.d/a.sh. a.sh contains the lines

    #!/ffp/bin/sh
    */5 * * * * /ffp/start/b.sh

    and b.sh contains the lines

    #!/ffp/bin/sh periscope -l fr /i-data/md0/x

    If I run sh /ffp/start/a.sh start the script is running fine but uwcron is not running anything.

    Does anyone have an ideea how to resolve this problem?

    1. If I run sh /ffp/start/b.sh start the script is running fine but ucron is not running anything. – i my first post the last 2 lines are typed wrong.

  19. I had the same reset issue of the other folks. I’m using Sylvian solution without the ‘uwcron’ and it’s working. I have the DNS-320L with 1.04 firmware and fun_plug 0.7.

  20. on my iomega ez-nas, crontabs are kept in the etc folder, not in the bin folder, so i’m getting the error:
    /ffp/start/uwcron.sh: line 19: /bin/crontab: No such file or directory
    /ffp/start/uwcron.sh: line 51: /bin/crontab: No such file or directory

    would it work if i changed the uwcron.sh file to point to the etc directory instead?

  21. I tried this on a DNS-345 with the last firmware released for it.

    I’m using this to run ddclient – a PERL script to update “any” DDNS service.

    At first, I seemed to have Jan’s problem. But since this is a Perl script, adding a shebang for SH would not work well. So instead a created a small SH script that is run by CRON. And that script has Jan’s recommended shebang. This seems to work.

    But, after a varying amount of time, my CRON list (as per crontab -l) gets reset back to the D-link value!

    I set my script up to run every 5 minutes, and it creates a log of the last run. So I can see that file date stamp updating as expected at least once. Then it stops, and the cron list is back to default.

    Its like I need another cron task to reset my cron tasks…

      1. No.

        I came to the conclusion that D-Link’s firmware is regularly CLEARING the cron list back to their default. So any changes will get removed – quite quickly. Adding something to run on reboot will not help; the drive is not rebooting.

        I solved my problem by writing my own DDNS updater in Python, and running it on the computer that is also the FAX/security camera machine, so its always running. This has worked perfectly!

    1. Oops … i mean something more along like a cron.daily but looks like that is not available in fun_plug right ?

  22. The simplest way is to create a file on startup, make it executable and put in it a command to copy your good crontab file over the default crontab file.
    For example: you have your custom crontab file named root in /i-data/somePath/root. The default crontab file name also root is located on /var/spool/cron/crontabs.
    You simply need to overwrite at startup the default crontab file with yours.
    To do this you need to create an executable file in /ffp/start/
    Let name it croninit.sh. The content of that file is:
    #! /ffp/bin/sh

    cp /i-Data/somePath/root /var/spool/cron/crontabs/
    to make it executable type on the command line:
    # chmod +x /ffp/start/croninit.sh
    That’s all.

Leave a Reply

Your email address will not be published. Required fields are marked *