You can visit https://crontab-generator.org/ it's a good tool for generating crontab lines and you will understand what the numbers and asterisks mean. Now if you choose
- 0 for minutes
- 2am for hour
- leave everything else as it is
- for the command use
cd ~/project_folder/application/logs; find . -type f -name "*.php" -mtime +4 -exec gzip {} \;
and click the generate crontab line you will see an example of the times it will run. Plus it will add this chuck >/dev/null 2>&1
don't worry about it, it's an output instruction for the command and good to have it in the crontab.

The argument to -mtime is interpreted as the number of whole days in the age of the file. -mtime +n means strictly greater than, -mtime -n means strictly less than.
So this command will find and gzip all the *.php
files where the latest modification time (mtime
) of those files are greater than 4 days.
Edit:
I couldn't recall the -k
argument of gzip
too. So as per @chang-qian response.
Without -k
, gzip
implies that it will delete the original files after their compression.