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