Reputation: 17
I'm looking for ways to have an automated process that checks the size of a flat file in a particular location if it is zero or otherwise. Currently, I am doing it manually by going to the location and to check it. This is tedious work since I'm doing this from time to time. Could someone guide me from here? It could be a shell script in a server that when I run, it will send an email to myself and others.
Hoping for your kind response. All I see here are batch files which is not applicable to me.
sample:
location
server_name/folder1/folder2/folder3
file: test_file.dat 0 bytes
Upvotes: 1
Views: 2674
Reputation: 9782
You could use something like this:
#!/bin/bash
# Test file with full path
if [ ! -s /tmp/test.dat ]; then
mail '[email protected]' -s 'test.dat is empty' < /dev/null
fi;
Create a cron job using crontab -e that will check every five minutes
*/5 * * * * /home/user/check.sh
Be sure to set the execute bit on /home/user/check.sh with
chmod +x /home/user/check.sh
Notes:
Upvotes: 2