Operating System - HP-UX
1752603 Members
5115 Online
108788 Solutions
New Discussion

cron executing wrong file

 
SOLVED
Go to solution
acroft
Visitor

cron executing wrong file

I need assistance troubleshooting a problem running a cron job on HP-UX B.11.31. I learned that this particular entry had ceased running a few months ago and went unnoticed until this week. During troubleshooting I found that the entry was firing, yet the output seemed to be from a different script file. No matter what changes are made to the original script in question it never executes the intended commands. I've setup the cron entry to direct standard output to one file and standard error to a separate file to see what's happening as such:

13 10 21 * * * /home/hci/test.sh > /tmp/log.txt 2> /tmp/error.txt

When this entry fires, I can verify it ran by checking the log in /var/adm/cron/log and double-checking the time stamps of the output files in /tmp. It clearly ran but error.txt has output obviously from another script file in the crontab. To further prove this to myself I added a line to the other script file to touch a new file in /tmp and to output the script's file location to standard output. This time I have a new file in /tmp generated from the other script and the file location matches the script file I suspected was being run in error. Here's what I've done so far.

-Ran the original script manual to verify it's working as expected.

- Checked file permissions and ownership

-Renamed the original file

-Moved the original file

-Renamed and moved the original file

-Moved the problem entry in the crontab to another location in the file

-Removed execute permissions from the other script; the output simply said the file did not have execute permission

-Saved a copy of the crontab, removed the crontab and verified it was gone from /var/spool/cron/crontabs, reinstated the crontab

I am not the system administrator for this system. I've spoken to the admin about this and we are both out of ideas. Could someone please suggest next troubleshooting steps?

2 REPLIES 2
Patrick Wallek
Honored Contributor
Solution

Re: cron executing wrong file

If this is truly your cron line:

 

13 10 21 * * * /home/hci/test.sh > /tmp/log.txt 2> /tmp/error.txt

 

You have too many entries.  You have an extra * field.

The fields are:

 

MINUTE HOUR  DAY-OF-MONTH MONTH WEEKDAY COMMAND-TO-RUN.

for a total of 6 fields.

You've got

MINUTE-(13) HOUR-(10) DAY-OF-MONTH-(21) MONTH-(*) WEEKDAY-(*) EXTRA-(*) COMMAND

The extra '*' could be causing you problems.  Try removing it and see what happens.

 

acroft
Visitor

Re: cron executing wrong file

Indeed, that was the problem. Thank you for responding.