0

I would like to write a script to run another script. When receiving a file from another machine; for example, if content in that file is "a" run example.sh And that file is needed to be watched all the time. Is it possible to do?

2
  • Have you done any research on cron jobs? Commented Mar 3, 2020 at 23:56
  • Yes. I used to use cron jobs to schedule task. Do you have guild for this purpose
    – Jess Brown
    Commented Mar 4, 2020 at 0:23

1 Answer 1

1

You can try something like this with inotify:

inotifywait -e moved_to -m receiving_dir/ | 
while read path action file; do 
  [[ $action = MOVED_TO && $(grep "a" $path$file) ]] && /home/user/./exampĺe.sh;
done
1
  • The entr program is also good for this kind of approach.
    – celadon
    Commented Mar 4, 2020 at 6:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .