I could use some assistance in making a PHP script that I could add to a cronjob that would include multiple, (10 to 15), commands such as:
line1: cat /dev/null > /var/www/vhosts/website.com
/logs/access_log.webstat
line2: cat /dev/null > /var/www/vhosts/website.com/logs/big_access_log
line3: cat /dev/null > /var/log/plesk-roundcube/largefile.log
and so on. The commands work great from a command line, but doing this daily is time consuming and the files grow way too large even though they are being rotated. Any assistance would be greatly appreciated, thank you.
4
Answers
Thank you all for your assistance, the ending outcome is a awesome! 41 log files will no longer grow to gargantuan sizes. The implementation was as follows:
PHP script written as such:
Then uploaded and set as a cron from the Plesk 12.5 panel. Tested and functioning beautifully!
Could you possibly use the
shell_exec
command to complete these actions:Example:
Then just create a cron job to run them at interval times.
You can easily achieve the same result using native PHP code:
It’s quite strange, by default this files should be rotated by psa-logrotate.
Maybe something happens with logrotate package or crontask.
Here is a default settings for rotating of domain’s logs: