'Setting log file for a cron job with the log file name as date

I am trying to set log file for a cron job and the name of the log file should be date.

The cron job is set like this.

55 09 * * * /home/program/my_folder/main.py &>> /home/program/my_folder/logs/file-`date"+\%Y"`-`date"+\%m"`-`date"+\%d"`.log

and in my main.py script i have added this code

 file_name = datetime.now().strftime('%Y-%m-%d.log')
 logging.basicConfig(filename='file-'+file_name,
                        level=logging.INFO,
                        format='%(asctime)s %(levelname)s %(message)s', )

But log filder name is not showing date name and logs are not coming. What could be the problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source