Reputation: 12064
Someone can help me write a small ssh script to test if file "/usr/modified.txt" has not been modified within 15 minutes, then start a command ./start.sh
Something like:
#!/bin/bash
if [ $date -gt 15 ]
then
/start.sh
fi
Upvotes: 0
Views: 1648
Reputation: 851
#!/bin/bash
if [[ $(find /usr/modified.txt -mmin +15) ]]; then
./start.sh
fi
Upvotes: 6
Reputation: 161914
You can use the basic commands date
and stat
:
#!/bin/bash
x=`stat -c %Y /usr/modified.txt`
y=`date -d '15 min ago' +%s`
if ((x < y)); then
/path/to/start.sh
fi
Upvotes: 2
Reputation: 323
@Phil, not quite.
-mtime is for days.
-mmin is for minutes
remember of course that this is with GNU find, which ships with most Linux distros but not all tradional nixes.
Upvotes: 0