You are not logged in.
hello folks
I wrote a simple nagios plugin which checks if mysql backup from the current date is available.
I pretty noobish in bash scripting and i just don't see the error
here's my script:
21 DATE=$(date '+%y-%m-%d')
22 STRING="*$DATE*"
23 COMMAND=`find . -name $STRING`
24
25 if [ echo "$COMMAND" | grep -q "$DATE" ]; then
26 echo "OK - Backup files found"
27 exit 0
28 else
29 echo "Critical - No Backups found today!"
30 exit 2
31 fiAs you can see, nothing special. When i execute it i get the following error:
./find.sh: line 25: [: missing `]'
grep: ]: No such file or directoryi KNOW this has to be some kind of pretty stupid error but i just don't see it. Anyone that can help me?
greetings
Offline
You can remove the brackets:
if echo "$COMMAND" | grep -q "$DATE"; thenOffline
Thank you very much!
Offline
#!/bin/bash
DATE=$(date '+%y-%m-%d')
if find | grep -q $DATE ; then
echo "OK - Backup files found"
exit 0
else
echo "Critical - No Backups found today!"
exit 2
fishould work too and it's a bit shorter.
Please remember to mark the thread as solved.
Offline