Task Scheduler not running script

Currently reading
Task Scheduler not running script

Hi everyone,

New Synology user here, having used a QNAP NAS for many years, when it had a failed motherboard around Christmas time I decided to try Synology - a DS720+

One of the tasks I use the NAS for is storing snapshots from several IP cameras. On the QNAP I added lines to the crontab to auto-delete these files when they were older than e.g. 7 days.

I was pleased to see that Synology provide a Task Scheduler to (hopefully!) save having to SSH in and edit the crontab file, so I have created some simple user-defined scripts in task scheduler, e.g.

find /volume1/FrontCam/ -type f -mtime +7 -delete

When I enable this task and click on "Run" it works perfectly. However, when left to run automatically once a day it does nothing at all. Output.log and Script.log files are created at the run time, which suggests that something is happening, but the output.log file is empty and the files are not deleted.

It makes no difference if I run it as User, admin or root.

A search indicates that this question, or a very similar one, has been asked several times in various forums but, as far as I can tell, has never been answered with a solution that works.

Can anyone shed any light on this and suggest how I can get it to work?

Thanks
 
Well I've finally managed to get it working, so if this is of any help to anyone what worked for me was running (in DSM 7)

systemctl restart crond

and

systemctl restart synoscheduler

As far as I know I had done nothing to stop the cron daemon. Could it be that entering user defined scripts in the Task Scheduler doesn't actually start it? Whatever, the above worked for me.
 
Well I absolutely agree - but as noted in my first post, it didn't. A search will reveal that I'm by no means the only one to have had this problem. Until the problem became evident I had not had any interaction with the Synology OS other than through the control panel, so I struggle to see how I could somehow have stopped either or both processes.
 
Well I'm only reporting my experience - the scheduled tasks did not run until I ssh'd in and ran those two commands as root. I posted in case that's of help to anyone else with the same problem. I'm very pleased for you if your scripts run OK, but that information doesn't really help anyone whose scripts don't. For example, someone answered the same question on another forum by saying the solution was to set the "last run time" to 23.59 - but if you have the schedule only running once per day there is no option to set a "last run time", so that solution may have worked for him, but was no use to me. The real question is why do some people have this problem at all, whilst others don't appear to?
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

I have a very similar script that runs every 15 mins. But I needed it to delay to around 1.5 minutes after...
Replies
3
Views
728
Hi, This code will delete oldest data or recently data? I also want to delete oldest data to newest...
Replies
2
Views
5,539
Thanks for the quick relay. Now I understand what the "Last run time" means.
Replies
2
Views
869
  • Question
The cron jobs are listed in file /etc/crontab. Looking in the file you can see most jobs are handled by...
Replies
1
Views
5,458
Thanks, but I don't see how that helps. My DS218 devices do support Snapshot & Replication, but as near...
Replies
2
Views
2,032
Shellcheck bash "/volume1/Base/install reaspberrypi/scripts/Defrag dsm.sh"
Replies
1
Views
4,381
It's probably taking a long time due to a number of reasons. There is this page in the online help (and...
Replies
1
Views
1,507

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Back
Top