问题
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"
回答1:
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
来源:https://stackoverflow.com/questions/23682186/what-is-script-working-differently-when-called-from-task-scheduler