LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron problem with script (https://www.linuxquestions.org/questions/linux-newbie-8/cron-problem-with-script-149739/)

lifetaster 02-23-2004 07:09 PM

cron problem with script
 
I wrote a script with logCat to retrieve log files. It functioned well after testing.
But, when I scheduled it with crontab, it executed at the time specified in the crontab files, but the problem is: the file generated by this script after auto executing was zero in size. when i tried it again by executing it, some contents were then generated.

retep 02-23-2004 08:23 PM

Most likely a bug in your script.

Try 'cd'ing' to a random directory. e.g. /usr and running the script using an absolute path. Sometimes I've seen scripts not work properly because they are run from different directories.

(And if you reproduce the problem this way, just specificy absolute paths in your script).

lifetaster 02-23-2004 08:49 PM

I did use the abs path,

#!/usr/bin/ksh
#testsize.sh
logCat -d /sms/smslog/alarm -l alm -a"02/23/2004" -z"02/24/2004" >/tmp/alm/Feb/test.log

the script above is used to retieve log files generated by telecom servers and format them.
$sh testsize.sh
or
$/usr/bin/ksh testsize.sh
or
$chmod 777 testsize.sh
$./testsize.sh
the above three method were all able to generate a non-zero test.log file.

while when scheduling with file named crontest shown below:
15 10 * * * /usr/bin/ksh /shome/sms/.../testsize.sh
the file test.log was also generated, but with zero size, viz nothing written in.

Thank you for your advice.

lifetaster 02-24-2004 12:26 AM

Solved!
I didn't specify the full path of logCat.


All times are GMT -5. The time now is 06:13 PM.