Operating System - HP-UX
1831315 Members
3099 Online
110023 Solutions
New Discussion

Re: Script for identifying when crontab has been modified

 
Roy Schauwecker
Occasional Advisor

Script for identifying when crontab has been modified

I've been trying to construct a script based off of some of the postings I've found in this forum. I'm doing a diff between the existing crontab and a "base" copy of the crontab. If it finds a difference, it sends me a message. Yes, I'm shell script challenged. Here's what I have to this point:

ll crontabs | awk '{print $9}' | while read name
do
diff crontabs/$name /cron/backup/$name> $name_crontabtext
if [ -s crontabtext ]
then
mail....

-----------------------

I run into this: Syntax error at line 4 : `&' is not expected.

Where am I going wrong?
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: Script for identifying when crontab has been modified

if looks as though your cut and paste got mangled all that [ and ] stuff should be square brackets.

if [[ -s "${name_crontabtext}" ]]
then
mail ...
fi

If it ain't broke, I can fix that.
Roy Schauwecker
Occasional Advisor

Re: Script for identifying when crontab has been modified

I actually found that [ stuff in this forum in multiple places. Is it just getting scrambled somehow? The intent is to check if the file $name_crontab is a zero byte file. If not send the email that the crontab has been modified. Is that what I'm accomplishing with the square brackets?