Operating System - HP-UX
1825795 Members
2211 Online
109687 Solutions
New Discussion

Re: what is wrong with this crontab entry ?

 
SOLVED
Go to solution
Rob Johnson_3
Regular Advisor

what is wrong with this crontab entry ?

This is mail that is generated as a result of the crontab entry:

johnsonr@nmscrme03 > mail
From johnsonr Tue Feb 7 12:11:15 2006
Date: Tue, 7 Feb 2006 12:11:15 -0500 (EST)
From: johnsonr
Message-Id: <200602071711.k17HBF707885@nmscrme03.kp.org>
To: johnsonr
Subject: Your crontab file has an error in it
Content-Length: 1084

Your "crontab" on nmscrme03

unexpected end of line
This entry has been ignored.


? n

This is the crontab entry:

johnsonr@nmscrme01 > crontab -e
"/tmp/crontabn9a4o2" 11 lines, 757 characters
00 8 * * * /opt/home/johnsonr/cronstuff/NC-CentralCron.sh > /dev/null
30 8 * * * /opt/home/johnsonr/cronstuff/NC-DONCron.sh > /dev/null
00 9 * * * /opt/home/johnsonr/cronstuff/NC-EastBayCron.sh > /dev/null
30 9 * * * /opt/home/johnsonr/cronstuff/NC-GoldenGateCron.sh > /dev/null
00 10 * * * /opt/home/johnsonr/cronstuff/NC-NorthBayCron.sh > /dev/null
30 10 * * * /opt/home/johnsonr/cronstuff/NC-SacrementoCron.sh > /dev/null
00 11 * * * /opt/home/johnsonr/cronstuff/NC-SouthBayCron.sh > /dev/null
00 6 * * 0,3 /opt/CSCOpx/bin/crmimport.pl /opt/IMS/tmp/cw2k_db.add

#script to watch for the process that communicates with the remote syslog server
30 * * * * $HOME/scripts/pswatch.sh >> /tmp/out 2>&1
14 REPLIES 14
Geoff Wild
Honored Contributor
Solution

Re: what is wrong with this crontab entry ?


You can use $HOME in cron...

Also, you might have garbage in it.....

do a crontab -l >z

then
od -Ad -tc -v z

Get rid of garbage, extr lines...

then

crontab z

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
TwoProc
Honored Contributor

Re: what is wrong with this crontab entry ?

Rob,

My guess is that it's the script that has $HOME in the command line.

Remove this and put the absolute path.

Keep in mind that when cron runs, its environment is extremely "light", and doesn't know much about defaulted variables. In most cases, this lack of defined environment variables is the cause of the problem.
We are the people our parents warned us about --Jimmy Buffett
A. Clay Stephenson
Acclaimed Contributor

Re: what is wrong with this crontab entry ?

The first glaring thing I see is $HOME. Very few environment variables are defined under cron.
If it ain't broke, I can fix that.
DCE
Honored Contributor

Re: what is wrong with this crontab entry ?


Rob,

You are better off using full path names instead of variables like $HOME - cron runs a limited shell and sometimes has problems with variables in command lines.

Also, have you tried remarking one line out at a time to see which one causes the error message?
Steven E. Protter
Exalted Contributor

Re: what is wrong with this crontab entry ?

Cron doesn't have access to $HOME.

It has almost no environment.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: what is wrong with this crontab entry ?

Hi Rob:

You have too many fields:

30 * * * * $HOME/scripts/pswatch.sh

Remove one splat ("*").

Regards!

...JRF...
Geoff Wild
Honored Contributor

Re: what is wrong with this crontab entry ?

My post should have said "can't" use $HOME in cron - fat finger syndrome - sorry....
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Arturo Galbiati
Esteemed Contributor

Re: what is wrong with this crontab entry ?

Hi,
I use $HOME in crontab from a lot of time (HP-UX11i) without any problem and the syntax:
30 * * * * $HOME/scripts/pswatch.sh >>/tmp/out 2>&1
it's ok.
Use:
crontab -l>crontabl.txt
strings crontabl.txt>crontabls.txt
diff crontabls.txt crontabl.txt

If ther are differencies means that at least one unprintable char in present in your crontab.

HTH,
Art

Art
Jakes Louw
Trusted Contributor

Re: what is wrong with this crontab entry ?

I picked that problem a short while ago with a NULL or empty line somewhere in the crontab entry: crontab will take the crontab -f but will not run properly. I see your crontab has an empty line before "#script to watch ....."
Remove this empty line.
Trying is the first step to failure - Homer Simpson
Nguyen Anh Tien
Honored Contributor

Re: what is wrong with this crontab entry ?

hmm!
1, check environment variable by
#env
2, set $HOME for correct your path where you script is located. Otherwise give full path for your scripts
HP is simple
Rob Johnson_3
Regular Advisor

Re: what is wrong with this crontab entry ?

Jakes Louw got it correct!!

It was the blank line before the #comment line.

It looks like cron doesn't like blank lines before an entry or after the last entry.

Also, I replaced the $HOME variable with the full path.

Thanks for you guys' help...
Muthukumar_5
Honored Contributor

Re: what is wrong with this crontab entry ?

As per crontab,

Blank lines and those whose first non-blank character is # will be
ignored.

So problem is because of $HOME variable. If you are using a environment variable then you have to export that in crontab setting. Else use the appropriate string instead of variable.

--
Muthu
Easy to suggest when don't know about the problem!
Babu Yalamanchi
Advisor

Re: what is wrong with this crontab entry ?

Hi
Cron supplies a default profile /etc/profile which does not have $HOME. When you login you have a login session for which $HOME is defined. Even if $HOME is used in /etc/profile it is only defined when you login. Try full path and see if it works.

Babu Yalamanchi
Rob Johnson_3
Regular Advisor

Re: what is wrong with this crontab entry ?

The problem was the blank lines before and after.

When I took the one before out and the one after out, it didn't produce an error.