What is script working differently when called from Task Scheduler?

半腔热情 提交于 2019-12-11 21:21:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!