LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   cron scripts (http://www.linuxquestions.org/questions/programming-9/cron-scripts-374604/)

kirmet 10-19-2005 06:21 AM

cron scripts
 
hi there

i have an understanding problem i hope you can help me with.

i did a small cron script to get info out of a log file every 15 min and wrote it into antoher file with a timestamp.

so i opened the crontab -e
and did

Code:

PATH=/root/getlog/
*/15 * * * * logres

and the script just does

Code:

echo `date` >> logres.date
echo /var/log/syslog | grep ....... | cut ..... > logres.ret

so now here come 2 questions:

1) The little script works perfect when i start it from commando line.
Starting the script with cron on the other hand i just pasts an empty line to logres.date.
What is the reason for that? some kind of permission problems?
I started the crontab for root.

2) When i extracted all the info from the log file i would like to get rid of the content. How can this be done without actually deleting the file.
My (bad) solution is rm and touch which leads to a problem. after that it gets no more entries until reboot.

could you please when you have time explain in few words what goes wrong and why?
learning about linux and always looking for answers.

david_ross 10-20-2005 12:37 PM

Looking at:
echo /var/log/syslog | grep ....... | cut ..... > logres.ret

Are you sure you don't want:
cat /var/log/syslog | grep ....... | cut ..... >> logres.ret


All times are GMT -5. The time now is 07:00 AM.