Reputation: 18524
Right now I append my php script's output to a logfile. Unfortunately it writes everything in one line. How do I need to change my cron command to append every execution log in a new line?
My current cronjob looks like this:
/usr/local/bin/php -q /home/username/public_html/forum/cron.php >> /home/username/cron.log 2>&1
Upvotes: 4
Views: 7505
Reputation: 836
I know this post is old however I do not believe the approach above was the best solution.
The solution above will add a new line everytime the cronjob is run.
Now this is fine if after everytime the cronjob runs there is output.
However, if there is no output then echo "" >> /home/username/cron.log
will print a new line into the cron.log.
I'd suggest adding "\n"
to the php file where the output echoed. Then remove the echo "" >> /home/username/cron.log
from the cronjob.
Eg:
echo "The cron job completed Successfully\n";
Upvotes: 6
Reputation: 18524
Solved by adding echo ""
as below:
/usr/local/bin/php -q /home/username/public_html/forum/cron.php >> /home/username/cron.log 2>&1; echo "" >> /home/username/cron.log
Upvotes: 7