Cygwin bash script-Windows 2003-Scheduled tasks not working problem
Posted on 2007-07-27
I have a windows 2003 server with cygwin installed.
I have written a bash script in cygwin that will let me tar a directory and ssh the tar dynamically over to another server (backupserver = remote linux server):
YDATE=$(date -d "1 day ago" +%d)
MONTH=$(date -d "1 day ago" +%m)
YEAR=$(date -d "1 day ago" +%Y)
tar cfz - /cygdrive/c/backupdir|ssh backupuser@backupserver "cat > /backups/backup."$YEAR"."$MONTH"."$YDATE".tar.gz"
This script runs fine under the non-admin user i have setup, backupuser, on the windows 2003 server, when doubleclicking the script c:\backup_process.bat, contents below:
c:\cygwin\bin\bash --login -c "bash /cygdrive/c/Documents\ and\ Settings/backupuser/backup.sh"
My situation now is that I want to automate this backup procedure. My first thought is to avoid installing the cron service from cygwin, and instead use the scheduled task function of windows 2003.
If I create a scheduled task under Administrator on windows 2003 set to run c:\backup_process.bat then the process works perfectly. the scheduled task runs at the right time, a dos prompt pops up and starts the tar/ssh process. However, I dont want to run this as Administrator.
Problem #1: logging on as backupuser and attempting to create a scheduled task, being non-admin, does not have access to "at" or scheduled tasks
Problem #2: if I create a scheduled task under Administrator on the windows 2003 server and set it to run as backupuser, then the task _shows_ as "running" in Scheduled Tasks, but no dos prompt pops up and the files are not backed up to backupserver.
The Scheduled Task log shows:
Started 27/07/2007 12:09:00
"backup.job" (backup_process.bat) 27/07/2007 12:11:21 ** WARNING **
The task was terminated. This action was initiated either by an administrator or by the Task Scheduler service (because, for example, the computer is now non idle).
The user backupuser on windows 2003 is part of the "logon as batch job" group in secpol.msc.. I can only conclude it's something to do with cygwin.
any ideas please anyone?