Question

What I am trying and tried to do:

I've written a Shellscript which should write some logs into a logfile. Something like:

    echo "downloaded header" >> log

I also tried with cat instead of echo and I've given full permissions to the log so it should be accessible for anyone. If I start the script from the command line everything works fine and the entries are made as expected. It didn't matter if I gave the full path to the logfile or not, I tried both.

The Problem:

If I run the script from crontab and yes It has to work with crontab, nothing is written into my log. So the echo "xy" >> log doesn't work, neither does the cat.

Any Ideas? Thanks in advance.

Was it helpful?

Solution

try this solution:

cat cronjob
* * * * * echo "downloaded header" >> /path/to/log

Then:

chmod +x cronjob
chmod +x script.sh

/etc/init.d/crond start  #redhat based servers like centos
/etc/init.d/cron  start  #debian based servers like ubuntu

crontab cronjob

OTHER TIPS

Try redirecting to the log file with full path

echo "downloaded header" >> $HOME/Log_dir/log  ## just an example
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top