shell script

CalmSoul
CalmSoul used Ask the Experts™
on
How can I write a shell script to execute windows batch file if c:\log.txt file is not updated in last 15 minutes.

If (log.txt is not update in last 15 min) then
execute windows batch script
else
do nothing

I have Cygwin installed
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Do you have to use Cygwin? Maybe powershell or vbs script is enough. You can then schedule such script in task scheduler.  

Author

Commented:
If you can do in vbscript tell me?

Author

Commented:
Do you have any?
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Steven CarnahanAssistant Vice President\Network Manager

Commented:
Please see my answer to the same question you easked earlier:   http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_26297863.html
Top Expert 2007
Commented:
Pretty easy with cygwin
#!/bin/bash
now=$(date +%s)
ts=(stat --format="%Y" /cygdrive/c/log.txt)

let diff="now-ts"

[ $diff -gt 60 ] && /cygdrive/c/file.bat

Open in new window

Author

Commented:
thanks Tintin:

I knew it

Author

Commented:
how to run this linux bash?

Author

Commented:
Tintin:

I am getting error

")syntax error: invalid arithmetic operator (error token is")
Top Expert 2007
Commented:
Whoops

ts=(stat --format="%Y" /cygdrive/c/log.txt)


should be

ts=$(stat --format="%Y" /cygdrive/c/log.txt)

Author

Commented:
Now getting this

")syntax error: invalid arithmetic operator (error token is") line 5: -gt unary operator expected

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial