cron not working.

I have a script monitor.sh

the path is /netmon/bin/monitor.sh

when i run this script as

sh /netmon/bin/monitor.sh it runs completely fine.

but when i include it in crontab , it does not run

my cron entry is

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /netmon/bin/monitor.sh

(the script should run every 5 min)

i have also included the environment variables in the begining of my script
as

env > monitor.sh

after that also it is not working

I searched the forum , the solution to include profiles is suggested

can anyone tell me how to do that.

Please suggest me if anyone knows the solution for this.

can you list the cronatb entry ? please execute crontab -l and see what you you get as output

Hi.

Why do you run the script manually as

sh /netmon/bin/monitor.sh

with sh? Is the file not executable? Can you check it?

To include your profile either source it in the cronjob or at the start of your script:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * . ~/.profile && /netmon/bin/monitor.sh

Also, if your cron supports it change

0,5,10,15,20,25,30,35,40,45,50,55
to
*/5

(because it looks nicer!)

To check:

man 5 crontab

45 09 * * * su - oracle -c /oracle/oracle/bin/top_job >/dev/null
15 3 * * * find / -name .nfs\* -mtime +7 -exec rm -f {} \; -o -fstype nfs -prune
5 4 * * 6 /usr/lib/newsyslog >/dev/null 2>&1
15 4 * * * find /var/preserve/ -mtime +7 -a -exec rm -f {} \;

the above is my crontab entry

also the server is old and */5 does not work in it

also if anyone can show me how to include profiles with an example, it will greatly help.

I do not know much about profiles

Thanks

---------- Post updated at 09:55 AM ---------- Previous update was at 09:52 AM ----------

sorry i included the profiles but its not working

my script is executable, i can directly use monitor.sh

and sorry scotn. I have seen the example given by you for profiles sorry for giving it . i missed on that . but that is also not working

please help

thanks

---------- Post updated at 09:56 AM ---------- Previous update was at 09:55 AM ----------

i have posted the entry

and the script you are talking about is

no reference in crontab list !!!!!

Which means your job is not entered into the cronatb. please submit it with crontab -e and see what you get

i wrote this entry first . but as this is a live server i removed it from the cron file

the entry was as it is in the cron file as i have mentioned

Thanks

I don't like the look of this line:

It will enquire about the current environment and put the output into a file called monitor.sh in whichever directory is current at the time the command is issued (hopefully not the same directory as your script of that name). It will however be useful to compare the results of "env" from cron against "env" from the command prompt, paying particular attention to PATH.

If your cron runs there will be entries in the cron log (usually /usr/adm/cron/log).
If the cron runs and produces an untrapped error message the error message will be in the mail file for the user who owns the cron (which in this case looks like root).

Hi methyl

i am new to this

so can you tell me how to collect env of cron and env of command promt by example.
it will be ver helpful

1) Check ur file has xecute permission?
If not please add chmod a+x filename

2) try to use full path for all commands which are useed inside the script.

3) type "mail" and see what is the error exactly.

Good luck

Thanks . my file was not executable . The cron is now running.

Thanks

That's amazing!

I asked:

You said:

Reply to the question about "env".
From the command prompt, just type "env". It will tell you what environment variables have been set during the login process. See "man login" for the full process.

To find out the environment in cron just create a one-time cron containing just and "env" command. The output will be in mail for the user owning the cron. You will see that the environment is quite limited and your script may need to add to the environment to work.