1834804 Members
3036 Online
110070 Solutions
New Discussion

Re: Cron not working

 
SOLVED
Go to solution
Bruce Baillie
Regular Advisor

Cron not working

I have 2 HP-UX 11.00 servers. I have a cron running on each that does hourly backups. It has been running fine for years. One is still working and one has stopped doing the hourly backups. I can run the script manually or copy and paste to the command line and it works. Cron will not run it with the error, find: missing conjunction. Here is the script.

rm -rf /temp/hourly.backups/monday/1pm/* #clear the directory
/usr/bin/find /aot1* /temp -newer /usr/local/bin/start.file -name *.prt | /usr/bin/cpio -pd /temp/hourly.backups/monday/1pm
/usr/bin/touch /usr/local/bin/start.file #reset the time
Why can't we all get along?
10 REPLIES 10
Vijaya Kumar_3
Respected Contributor

Re: Cron not working

Looks like you have some issues with the find command.

Refer this thread:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=182956

Regards
Vijay Chinnasamy
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Vijaya Kumar_3
Respected Contributor

Re: Cron not working

More detailed thread is this:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x958f8cc5e03fd6118fff0090279
cd0f9,00.html

Regards
Vijay Chinnasamy
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Mel Burslan
Honored Contributor

Re: Cron not working

I would suspect an accidental insetion of a carriage return in that long cron line of yours or some other typo, when somebody was trying to edit this file for adding or deleting a cron job from it.
________________________________
UNIX because I majored in cryptology...
Vijaya Kumar_3
Respected Contributor

Re: Cron not working

Compare the .profile settings from the both the systems. Also I would recommend to do a compare betweek /etc/profile as well.

Which shell you are running this with?

Regards
Vijay Chinnasamy
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Patrick Wallek
Honored Contributor

Re: Cron not working

What does /var/adm/cron/log tell you?

What has changed? Things don't normally just stop working.
James R. Ferguson
Acclaimed Contributor

Re: Cron not working

Hi Bruce:

One thing I see that may be the source of your problem is the expansion of "/aot1*". The expansion by the shell *before* find() runs may be causing the error.

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Cron not working

Your code was poorly constructed and you have been fortunate that it has not bitten you before now. It has been an accident waiting to happen.

The problem is that the shell is instantiating *.prt before the find command ever sees it. As soon as 2 or more files in the same directory match that pattern, find cannot parse it. The correction is quite simple: ..prt becomes "*.prt" or slightly better still '*.prt'. Now that the expression is within quotes, the find command rather than the shell does the expansion of the expression.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: Cron not working

Hi (again) Bruce:

Yes, Clay nailed it. To prove it simply do:

# cd /aot1
# echo *.prt

...This will cause the shell to expand all of the matching files. You will (when the failure occurs) see multiple files.

Regards!

...JRF...
Bruce Baillie
Regular Advisor

Re: Cron not working

Thanks Clay, putting *.prt in quotes solved the problem.

I know the command was not the greatest but it worked. I still don't know why it broke. Nothing on the system has changed and I am the only user. The error message was in the mail not the cron log.
Why can't we all get along?
A. Clay Stephenson
Acclaimed Contributor

Re: Cron not working

What happened is very simple. You had 2 or more files that matched *.prt in the current working directory when the find command was invoked. The rule for the -name find option is very simple -- always quote it. If the pattern string is constant (as in your case) then use single quotes. If variable substitution should take place before the find then (e.g. "*${MYVAR}.prt") then double quotes should be used. Of course, I always enclose variables in {}'s too -- even when I don't "need" to. I simply don't like code (even inside my head) then needlessly branches.
If it ain't broke, I can fix that.