How to use cron on a Synology NAS

Unlike other Linux based systems, “crontab -e” won’t work on the Synology NAS.

Modifying crontab and enabling the deamon

  1. Become root
    sudo -i
    
  2. Edit /etc/crontab
    nano /etc/crontab
    
  3. Restart the cron deamon by typing:
    synoservice -restart crond
    

Note: After a shutdown or reboot, you’ll need to restart the cron deamon to enable it again.

Running tasks using a different user account

If you want to run a task under a different user than root you can do the following:

#min    hour            mday    month   wday    who     command
30      0,6,12,18       *       *       *       root    /bin/su -c "/var/services/homes/myuser/apps/flexget.sh" myuser

The task above will run a flexget script under the username myuser ever 4 hours.


4 responses

  1. Hi, I’m interested about running a cronjob with a different user than root. I was wondering if my code below needs any “escape” characters? I know have have many double quotes, so maybe that’s why it is not running. */15 * * * * root /bin/su -c “filebot -rename -r -extract /volume1/download/tmp/ –output “/volume1/Video/TV Shows” –format “{n}/Season {s}/{n} {sxe} {t}” –db TheTVDB -non-strict” user1 Here’s my issue: I have a cronjob to move completed files to a different directory, but when it moves them it creates a directory under the “owner 0” (aka root). This is not good, cuz I cannot see the files in my media player on my TV :(. They must be under a user I have. Any help would be appreciated. Thanks.

    Hector – September 1st, 2013
  2. Use a cron job with the chown command to change the ownership of the produced files. Alternately use chmod to allow you to read those files (chmod 644)

    Usolis – May 30th, 2015
  3. What can cron do that tte Synology Task Scheduler can’t? The Synology Task Scheduler also handles some other task, like mailing errors.

    RabanePaco – February 14th, 2021
  4. Hour 0,6,12,18 is every 6 hours, not every 4. And why not use */6 in that case?

    IvD – October 13th, 2022