Domanda

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"
È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top