Task Scheduler - Script not running

Questions pertaining to Power settings, Auto Block, Permissions, User Quotas and Email alerts may be posted here.
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:

https://account.synology.com/support/su ... p?lang=enu

2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
I'm New!
I'm New!
Posts: 1
Joined: Wed Jun 13, 2018 10:23 am

Task Scheduler - Script not running

Unread post by Fluwk » Wed Jun 13, 2018 10:34 am


I was working on a script to move all subfolders and files from a specific folder to a 'archive' folder.
When executing the commands via SSH, all is fine but when I upload the script to my NAS, give it chmod 775 and execute it on the task scheduler nothing happens.
I've added a line for debugging in the task scheduler, the error code is pasted below.

This is what the script looks like:

Code: Select all

cd "/volume1/<folder>/"
mkdir "$(date +"%d-%m-%Y")"
cd /volume1/<folder>/
mv * "/volume1/<archive folder>/$(date +"%d-%m-%Y")"
This is what the 'User defined script' looks like in the task mananger:

Code: Select all

/bin/bash /volume1/<folder>/MoveFilesFromGuestToArchive.bash >>/tmp/task_debug.out 2>&1 
The Error code in the debug looks like this

Code: Select all

/volume1/<script folder>/MoveFilesFromGuestToArchive.bash: line 1: <feff>#!/bin/sh^M: No such file or directory
/volume1/<script folder>/MoveFilesFromGuestToArchive.bash: line 2: cd: /volume1/<archive folder>/^M: No such file or directory
mkdir: cannot create directory '13-06-2018\r': File exists
/volume1/<script folder>/MoveFilesFromGuestToArchive.bash: line 4: cd: /volume1/<folder>/^M: No such file or directory
mv: target '/volume1/<archive folder>/13-06-2018' is not a directory
I did notice the '<feff>' and '^M' code but already tried setting this to UNIX format with Vim.

If anyone can help me out with the problem, i'd be gratefull! :D


User avatar
Posts: 3148
Joined: Fri Jun 03, 2011 10:51 pm

Re: Task Scheduler - Script not running

Unread post by Rusty1281 » Wed Jun 13, 2018 12:15 pm

Guessing you are running that script as root account or?
Synology DS918+ (4x4TB WD RED - RAID 5 with 2x250GB 960EVO NVMe) | Synology DS412+ (4x3TB WD RED - RAID 5) | RT1900AC

Posts: 596
Joined: Tue Feb 12, 2013 7:53 pm

Re: Task Scheduler - Script not running

Unread post by pwhooftman » Wed Jun 13, 2018 7:29 pm

open the script in an editor like vi and remove all those ^M like codes.
DS918+ with 2x4Tb WD Red, Kopano VM, Domoticz

User avatar
Posts: 132
Joined: Thu Sep 05, 2013 9:35 am

Re: Task Scheduler - Script not running

Unread post by sciurius » Sun Jul 29, 2018 12:50 pm

The <feff> and ^M stuff indicates that the script was saved in UTF16 for DOS, with BOM. Try to save it in plain ASCII instead.
DS418 / DSM 6.2-23739 Update 2 / 2 x WD40EFRX-68WT0N0 (SHR) / MailServer / MailStation / ownCloud / Transmission / ResilioSync / Syncthing / spotweb / LMS+Spotify
DS413 / DSM 6.2-23739 Update 2 / 2 x ST3000DM001-1CH166 (SHR) / Testing

Post Reply

Return to “System Management”