• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

Cron script for Linux to search for a file and then execute a function

I would like to create a Cron job that would search the a specific file in the Linux file system at a designated location.  If the file is found I want the script to execute a some additon code and if not just exit the script.  Is this possible?
0
WH_Tech
Asked:
WH_Tech
2 Solutions
 
TintinCommented:
Something like

0 0 * * * [ -f /some/file ] && additional code
0
 
woolmilkporcCommented:
Yep.

* * * * * [ -e /your/designated/file ] && /path/to/code > /path/to/logfile 2>/path/to/errorlog

Replace the asterisks with your desired schduling times. Use >> instead of > to append to the logfiles instead of replacing them.

wmp
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now