So, it was that kind of day. Time to document a thing…

Screen Shot 2022 04 08 at 2.26.42 PM

To clear your php-fpm logs daily, set up a CRON job to run the following script. You will need to update the log file path and script path to work with your setup – I have multiple PHP versions installed on Mac via homebrew.

#!/bin/sh
# daily clean php-fpm logs
# 0 0 * * * sh /Users/kevin/Dev/CRON/mac.sh
LOGFILE=/opt/homebrew/var/log/php-fpm.log

if test -f "$LOGFILE"; then
    echo "$LOGFILE exists."
    echo "" > "$LOGFILE"
    echo "$LOGFILE contents:"
    tail "$LOGFILE"
else 
    echo "$LOGFILE does not exist."
fi

Now, add it to your Mac’s CRON with crontab -e.

0 0 * * * sh /Users/kevin/Dev/CRON/mac.sh

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Involved & Explore More

an abstract painting with blue and yellow colors

Catch up on what I’ve been writing lately.

Show your gratitude.

Join Dare To Code Email List

Get emails from me on full-stack PHP development by subscribing to the Dare To Code mailing list.