How to modify crontab in DSM5?

Questions that don't fit in any category below may go here
Forum rules
We've moved! Head over to Synology Community (community.synology.com) to meet up with our team and other Synology enthusiasts!
Jmag
I'm New!
I'm New!
Posts: 5
Joined: Wed Oct 22, 2014 1:22 pm

How to modify crontab in DSM5?

Unread post by Jmag » Wed Oct 22, 2014 6:10 pm

I am trying to install freenet (for linux) on my DS412+ but the install script does not execute properly as crontab -l command does not seem to be working.

How do I add an entry in crontab in DSM if crontab -l is not working? (besides edit it manually)

jmag

User avatar
CoolRaoul
Seasoned
Seasoned
Posts: 560
Joined: Tue May 18, 2010 7:08 pm

Re: How to modify crontab in DSM5?

Unread post by CoolRaoul » Wed Oct 22, 2014 7:49 pm

You may either direclly edit /etc/crontab using "vi", or use built task scheduler (in DSM control panel) which modify crontab behind the hoods preventing syntax error (DSM/busybox cron is very "touchy" regarding tabs vs space characters)

If you choose the 1st method, after edits, execute command "synoservicecfg --restart crond" to force cron to reload updates.
CR

Jmag
I'm New!
I'm New!
Posts: 5
Joined: Wed Oct 22, 2014 1:22 pm

Re: How to modify crontab in DSM5?

Unread post by Jmag » Fri Oct 24, 2014 12:55 pm

Thanks for the answer CoolRaoul.

My underlying issue is that the freenet installer uses the crontab -l command it to schedule the deamon to start on reboot. Moreover, the script must not be run as root (several scripts check for it in the code, so must be risky...).

The script also uses cron and to overcome that I aliased crond as cron.

During my explorations on these forums, I have found a very usefull crontab script to add the crontab functionality to the command line. Unfortunately this script only allows to add crontab entries as root (there are also reasons for that...). I could change it easily but, as explained above, it is not wise to run this app as root.

I went even further and installed ipkg and bash. Bash is now my default shell.

The environment is getting friendlier... :-}

So, I am somewhat stuck due this conflict of permissions: I need a non-root user to run the script than needs to modify a root-permission file.

Any sugestions? su and sudo commands are not available.

jmag

User avatar
johnk.dev.null
Versed
Versed
Posts: 274
Joined: Tue Apr 02, 2013 8:00 pm
Location: UK

Re: How to modify crontab in DSM5?

Unread post by johnk.dev.null » Fri Oct 24, 2014 2:11 pm

Synology cron ignores the user specified on the crontab line and always runs as root. It is only through using the web GUI that cronjobs running as users is supported. It does that by running a synoschedtask executable for the job which handles changing the UID.
Synology cron also does NOT support special event schedules like on reboot.

So for those reasons you will have to customise the Freenet installer.
If you want to run the task as a non-root user then I suggest a crontab line in this format -

* * * * * root /bin/su freenetaccount -c "/opt/bin/freenet_command run options"
DSM 6.1.5-15254 Update 1

Amadeus1756
Rookie
Rookie
Posts: 30
Joined: Fri Dec 03, 2010 11:07 pm

Re: How to modify crontab in DSM5?

Unread post by Amadeus1756 » Tue Nov 11, 2014 9:34 pm

Would it be possible to use the setuid bit?

Locked

Return to “General Mods”