I have a p开发者_开发技巧hp cron job that writes its output to a log file like this:
crontab -l
* * * * * php -f /var/www/cron.php >> /tmp/crons/cron.log
Is there a way of making the log output file dynamic, so that it could write to date('Y-m').cron.log?
I'm not sure what cron uses to execute the commands, but in bash you could use backticks. So, with your crontab like this:
* * * * * bash /your/script.sh
and /your/script.sh containing this:
#!/bin/bash
php -f /var/www/cron.php >> /tmp/crons/`date +%Y-%m`.cron.log
you'll get that which you desire.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论