none
check file exists and with the time stamp RRS feed

  • Question

  • In runbook, I want to run an .bat file using run program.

    But first I'd like to check if a flat file is generated with today's within 24 hours or not, if so, then than run the bat file otherwise do nothing.

    How can do the highlighted part?

    The file is supposed to be generated each night by overwriting.


    Thanks


    Thanks

    Friday, November 22, 2019 10:38 PM

Answers

All replies

  • Hi,

    You have at least two options:

    You can use the builtin Get File Status activity and schedule it with a Monitor Date/Time activity.

    Example:

    Another way is to use a Run .Net Script and implement a check with PowerShell and schedule it with a Monitor Date/Time activity.

    Best regards,
    Leon


    Blog: https://thesystemcenterblog.com LinkedIn:

    • Marked as answer by msloy Saturday, November 23, 2019 12:14 AM
    Friday, November 22, 2019 11:13 PM
  • so the link filter file exists from get file status equals true, does this mean not only check if the file exists but also the is less than 1 day?

    Thanks much


    Thanks

    Saturday, November 23, 2019 12:14 AM
  • It follows the condition that is set in the Get File Status activity.

    Blog: https://thesystemcenterblog.com LinkedIn:

    • Marked as answer by msloy Saturday, November 23, 2019 12:28 AM
    Saturday, November 23, 2019 12:16 AM
  • I used the monitor and check schedule since I want it run daily at 8:00 pm,

    Then I added the check file status activity, to check for less than 1 day just as your screenshot above, but even the file is generated this afternoon, which is less than a day, it still goes to the link of file does not exist and send email.

    I changed to less than 2 days on the screen, still thinks the file does not exist.

    does it matter I have a space in the path of the file, if so how can I resolve?

    \\mymachine\my folder\myfile.txt


    Thanks


    • Edited by msloy Saturday, November 23, 2019 1:17 AM
    Saturday, November 23, 2019 1:10 AM
  • Spaces doesn't matter.

    It's probably better to use a better condition than "File Exists", it was just a simple example from me.

    Try using for example:

    File name from Get File Status contains <InsertYourTextFileName>


    Blog: https://thesystemcenterblog.com LinkedIn:

    • Marked as answer by msloy Saturday, November 23, 2019 5:17 PM
    Saturday, November 23, 2019 8:48 AM
  • Thanks so much, it works!

    It is strange check the file exists does not work, but check name works. 

    Also I wonder what does the file age is less than 1 day mean?

    if the file is created a month ago, and overwrite daily, does the file age mean it is 30 days or 1 day?


    Thanks


    • Edited by msloy Saturday, November 23, 2019 5:24 PM
    Saturday, November 23, 2019 5:18 PM