1833780 Members
2688 Online
110063 Solutions
New Discussion

Re: Cron troubles

 
Jeffrey F. Goldsmith
Super Advisor

Cron troubles

I created a cron job to run a script that resides in /root folder. This script doesn’t do very much but give me a picture of how the system is doing at midnight and removes old files from the /tmp folder.

It sends an e-mail to the user (root) which should be forwarded to my e-mail address. This works properly won my L2000 server but doesn’t seem to be working on my rp3440 server.

The log file doesn’t show me any useful information other than the script ran. I am not getting any e-mails. What could be the problem?

Thanks
16 REPLIES 16
James R. Ferguson
Acclaimed Contributor

Re: Cron troubles

Hi Jeffrey:

How do you do 'forwarding'? Is your "email" address merely on your server or does it live elsewhere? Do you have a 'DS' entry in:

'/etc/mail/sendmail.cf'

...for example:

DSxxx.abc.com

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Cron troubles

Hi (again) Jeff:

Check also '/var/adm/syslog/mail.log' for indications of mail problems.

Regards!

...JRF...
Carlos Roberto Schimidt
Regular Advisor

Re: Cron troubles

Hi,

Do you PATH setup in your script to find sendmail or mailx ?

Try put to run in cron this form:

0 0 * * * /your_script.sh 2>/tmp/err.log >/tmp/your_script.log

Look for the errors in theses logs.

Try put "set -x" in first line in script if you can figure out yet.

Look for errors in /var/adm/syslog/mail.log

Be sure your script in the log /var/adm/cron/log

Schimidt
Sandman!
Honored Contributor

Re: Cron troubles

Run your script in debug mode by adding a line to the top of your script as follows:

#!/bin/ -x

and then looking at its output on what is wrong. Additionally make sure the PATH variable in your script is defined as cron has a very limited one.

cheers!
Geoff Wild
Honored Contributor

Re: Cron troubles

Could be many things - different OS releases?

Mail not configured the same?

Can you post the script?

In your crontab, ad looging for the cron job:

0 0 0 0 0 /root/yourscript > /tmp/yourscript.cronlog 2>&1

What happens when you run the script from the command line on the rp3440?

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.
Jeffrey F. Goldsmith
Super Advisor

Re: Cron troubles

Yes, there is a difference between the OS that I am using. The L2000 is using HP-UX 11.0 and the rp3440 is using HP-UX 11.23.

Here is the script that I am running on both servers:

Kent Ostby
Honored Contributor

Re: Cron troubles

Check to make sure that you are using full paths in your script.

If the paths are defined differently between the two machines then it could cause a problem.
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Geoff Wild
Honored Contributor

Re: Cron troubles

In your script, you can also redirect command outputs to a log file:

LOG=/tmp/genadmin.log

#zero the old log
>$LOG

bdf >>$LOG

swapinfo -tam >> $LOG

and so on...

Then mail the log file:

mailx -s "genadmin report" you@yourdomain.com < $LOG

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.
Jeffrey F. Goldsmith
Super Advisor

Re: Cron troubles

The PATHs are different because of how I setup the root user on the rp3440. Here is the two scrips that are running on the two different servers.


Rp3440 w/11.23:
root: /var/spool/cron/crontabs ==> more root
# Entry(s) in /opt/hpservices/RemoteSupport are for HP Instant Support Enterpris
e Edition

0 0 * * 1 /opt/hpservices/RemoteSupport/config/pruneIncidents.sh
50 23 * * * /root/genadmin
0,15,30,45 * * * * /opt/omni/sbin/omnitrig
root: /var/spool/cron/crontabs ==>


L2000 w/11.0:
root: /etc/mail ==> more /var/spool/cron/crontabs/root
50 23 * * * /home/root/genadmin
# omnitrig entry was automatically added by
0,15,30,45 * * * * /opt/omni/sbin/omnitrig
root: /etc/mail ==>
Geoff Wild
Honored Contributor

Re: Cron troubles

What Kent means - is in your scripts, use the full paths to the commands:

/usr/bin/bdf

I also noticed the first line in your script:

#\!/bin/ksh

should be

#!/bin/ksh

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.
Jeffrey F. Goldsmith
Super Advisor

Re: Cron troubles

I made the changes and also created a different script to see if I could figure out what the problem is. This one doesnt seem to be working either.

root: /root ==> more gravinadate
#!/bin/ksh -x

/usr/bin/date

# mail lvol list to root
/usr/bin/bdf

root: /root ==>


Here is my crontabs file:

root: /var/spool/cron/crontabs ==> more root
# Entry(s) in /opt/hpservices/RemoteSupport are for HP Instant Support Enterpris
e Edition

0 0 0 0 0 /root/gravinadate > /tmp/gravinadate.cronlog 2>&1

0 0 * * 1 /opt/hpservices/RemoteSupport/config/pruneIncidents.sh
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /root/gravinadate
50 23 * * * /root/genadmin
0,15,30,45 * * * * /opt/omni/sbin/omnitrig
root: /var/spool/cron/crontabs ==>

Here is my .forward too:

root: /root ==> more .forward
jgoldsmith@co.fairbanks.ak.us
# ssmith@co.fairbanks.ak.us
root: /root ==>

I checked the mail part and it looks correct.
Any other ideas as to what could be my problem?
Marcel Boogert_1
Trusted Contributor

Re: Cron troubles

Hi,

You mail setup is working well?

# cat /root/.profile | mailx jgoldsmith@co.fairbanks.ak.us

Use the command mailq to see if anything hangs...

Regards, MB.
Marcel Boogert_1
Trusted Contributor

Re: Cron troubles

Jeffrey F. Goldsmith
Super Advisor

Re: Cron troubles

I am now thinking that I am having a problem with my mail service. I tried to send myself an e-mail and received nothing and the mqueue is empty.

someone_4
Honored Contributor

Re: Cron troubles

Here is what i do:
------------------------
#!/bin/sh
exec > /home/whatever/logfile 2>@1

MAIL_TO=you@somewhere.net

echo "From:yourserver@somewhere.net"
echo "Subject:whatever you want.


your script here:


bottom of script

cat /home/whatever/logfile | sendmail $MAIL_TO
----------------------------



Richard

Geoff Wild
Honored Contributor

Re: Cron troubles

Yes - check your mail configuration...

/etc/mail

look at the aliases file and sendmail.cf

Main macros to check in cf:

DS
DM

Check it on the L2000 - then make changes to the sendmail.cf on the RP3440.

DS is the "smart relay" - like an exchange or notes server

DSyourexchangeserver

DM - is masquerade - so instead of root@someserver.internaldomain.net it will be root@yourdomain.com

DMyourdomain.com

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.