Cronjob is NOT working

Hi;

Here is the output from crontab -l :

2,7,12,17,22,27,32,37,42,47,52,57 * * * * /var/tmp/gcsw/jmap_samples/jmap_script.sh > /var/tmp/gcsw/jmap_samples/histo_`date '+%Y%m%d%H%M'`.txt

When I manually run the line: /var/tmp/gcsw/jmap_samples/jmap_script.sh > /var/tmp/gcsw/jmap_samples/histo_`date '+%Y%m%d%H%M'`.txt , everything is OK. but when it comes to cronjob, no file produced :confused:

my file is 777:

gc:jmap_samples> pwd
/var/tmp/gcsw/jmap_samples
gc:jmap_samples> ls -lah
total 12K
drwxrwxrwx 2 na na 4.0K Jan 23 12:18 .
drwxrwxrwx 3 na na 4.0K Jan 23 10:11 ..
-rwxrwxrwx 1 na na   56 Jan 23 12:17 jmap_script.sh

and the file content:

gc:jmap_samples> more jmap_script.sh
#!/bin/bash
/opt/jdk/bin/jmap -histo:live 27712
gc:jmap_samples>

so, what is wrong??

Try moving:
> /var/tmp/gcsw/jmap_samples/histo_`date '+%Y%m%d%H%M'`.txt
into the script.

Another possible cause could be that your date call has no absolute path.

Just for the optics, i know your 5 minute time intervall starting at 2minute of each hour could be written simpler.
Not sure if this would work though!!: 2/5 instead of 2,7,12,17,22,27,32,37,42,47,52,57
Better try the other 2 changes first.

hth

You have to be aware that the environment that cron fires up is not the same that you get when you log on. There could be differences in the PATH and other variables that mean this doesn't work. Perhaps you could schedule a script that does the following:-

env > /tmp/my.cron.env
set > /tmp/my.cron.set

If you can also do this on the command line:

env > /tmp/my.login.env
set > /tmp/my.login.set

... then you can compare the two and see what you need to add to your scheduled script to make the environments the same.

There are already numerous threads with similar issues, so we're all fallen over then at some point. Hopefully the other threads will also have more advice that will get you sorted out.

Robin

Robin