Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1085  / 1 Year ago, wed, december 28, 2022, 3:46:09

I'm trying to delete logs file in a container with cron:



$ crontab -e
# I add this line to file, must execute each 10 minutes
10 * * * * docker exec -it explorer.org1.company.fr sh -c 'rm /opt/logs/app/app.log-*'


When I check cron logs with



 grep CRON /var/log/syslog


I get:



Jan 22 09:10:01 ip-172-31-46-123 CRON[4029]: (ubuntu) CMD (docker exec -it  explorer.org1.company.fr sh -c 'rm /opt/logs/app/app.log-*')


Which seems to indicate that cron command triggered.



But when I check the files with:



docker exec -it  explorer.org1.company.fr sh -c 'ls /opt/logs/app'


the files haven't been deleted.



If I execute the command manually, it will delete the 2 files, so it confirms command is working.



Why is the command not effective when running with cron ???


More From » bash

 Answers
6

After installing Postfix / Mutt, I could get the error message:



the input device is not a TTY


That is discussed here



Removing -it after docker exec did the trick!



Thanks for your help!


[#4243] Thursday, December 29, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ugeeport

Total Points: 181
Total Questions: 108
Total Answers: 99

Location: El Salvador
Member since Tue, Jun 29, 2021
3 Years ago
;