I want to define a cronjob like this:
@hourly /path/to/my/script.sh &> "/path/to/my/logs/$(date +%Y-%m-%d_%H-%M-%S.txt)"
So it should write the output of the script to a log file. Now I want to make a second script (preferably with PHP) that reads all files in /path/to/my/logs/
and sends the files via mail. It shouldn't be a problem to create such a script, but I wonder how I can detect if the cronjob that created a file is done and no longer writing to the file. I don't want to send a file that was created but the cronjob still writes to.
Is there a general way to detect that and also a way in PHP to detect that?
&>
will not behave the way you expect unless you explicitly change theSHELL
. – steeldriver Mar 04 '21 at 15:45