I have this script that I have scheduled on WIndows 7 using:

SchTasks /Create /SC MINUTE  /TN CheckHS /TR "C:\cygwin64\bin\bash.exe C:\ShellStuff\checkHS.SH"

The script runs, but a BLANK line is written to checklog, when run from the scheduler. If I run the script from terminal the DATE gets added correctly. Why is it acting differently from the scheduler?

checkHS.SH:

#!/bin/sh
set -x 

LOGDIR="/myd/Logs/"

CURDATE=`date '+%A %W %Y %X'`

echo $CURDATE >> $LOGDIR"checkLog"
有帮助吗?

解决方案

Try after adding full path to date command,

CURDATE=$(/usr/bin/date '+%A %W %Y %X')

OR in Your case enter the Correct path to date

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top