Currently i had a requirement in my opensource project to run the jobs not on holidays.In the previous post, i have tried with grouping the datas into arrays and then comparing with current date.
Now in this post i tried with the grep method and then on fetching the exit status or $? we can able do the logic or run other scripts.
How my script look likes
#!/usr/bash
#By default i have used date, if u want to change the format.You can try like date +%Y-%m-%d or you can have a better understanding from this post
grep -i date holiday.txt
#date is the default current date of the system & holiday.txt is the file having the collection of holidays
Now on checking the $? the status of the above command we can achieve our target
$? status will be 0, when the current date matches with date from the text.
if[ $? -ne 0] then;
#script to run the jobs
exit
fi
Finally the code will be much more simpler than the code in my previous post
#!/bin/bash
grep -i date holiday.txt
if[ $? -ne 0] then;
#script to run the jobs
exit
fi
Subscribe to:
Post Comments
(
Atom
)
Hi buddy,
ReplyDeletei am working as a web developer in chennai..
i had read your script,its very useful for my profession..i am looking for a good relationship with you..