I have a shell script with the following Command
/vs/bin/display message priority critical start '09/14 11:00:00' stop '09/15 10:59:59' all >> /unused1/Monitoring/Log/log.txt
Where i want the date part to update automatically by a day,
Please advice.
thegeek
2
Execute the following script in cron daily, so it will change that date accordingly.
tomorrow=`date --date='tomorrow' +%m/%d`
today=`date +%m/%d`
date='[0-9]\+/[0-9]\+'
sed "s#start '$date\(.*stop '\)$date#start '$today\1$tomorrow#" <FILENAME>
Note: If the pattern matches only this line, it will change correctly. If you have some other line also that matches it, then you are in trouble..
- Give that shell script filename instead of <FILENAME>
- Once after you tested that above worked correctly, add the -i option to sed command which will edit that file itself.