Info Scheduled task - run script to your schedule

Currently reading
Info Scheduled task - run script to your schedule

fredbert

Moderator
NAS Support
Subscriber
5,148
2,084
NAS
DS1520+, DS218+, DS215j
Router
  1. RT2600ac
  2. MR2200ac
  3. RT6600ax
  4. WRX560
Operating system
  1. macOS
Mobile operating system
  1. iOS
A simple trick to adjust the scheduled run time of a script is to use the unix sleep command as the top of the script.

Example: I have a script that copies files from one remote folder to another local one. The remote server creates the new files on each quarter hour. The files take just over a minute to complete.

I therefore want to be over a minute past each quarter hour before starting the copy to the NAS. But DSM's task scheduler only gives me options to run tasks every 1, 5, 15 mins, etc. So instead of running the task every minute and working out if the current minute is one I want (using complicated expansion of if ... date +%m = <min I want> ... then ...) I select the task to run every 15 minutes (00/15/30/45) and within the script it starts:
Bash:
#!/bin/bash

#run every 1/4 hour but wait for files to be updated (1.5 mins delay)
sleep 90s

<rest of script>


I prefer to copy the files to the NAS than have the remote folders mounted in /web and directly accessed from the Internet (even if the remote shares are read-only).
 

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

That is exactly what I do. Probably an old habit from admin days.
Replies
3
Views
4,737
Thanks ! I overlooked the Triggered Task option
Replies
6
Views
5,663
Replies
1
Views
4,459

Welcome to SynoForum.com!

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

Registration is free, easy and fast!

Trending threads

Back
Top