Pregunta

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"
¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top