D
D
Dmitry2021-10-05 15:34:44
Debian
Dmitry, 2021-10-05 15:34:44

Correct options for cron?

Good afternoon.

There is a server running jenkins.
Cron has a command to clean up old dind images.

0 2 * * * /bin/sh -c 'cd /home/deploy/jenkins && /usr/local/bin/docker-compose exec docker docker system prune -af --filter until=240h'

Naturally, it does not work)))
If you log into the server via ssh as root and run the command manually, everything works, the old images are deleted.
The command itself is written specifically for root.


Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster


How can the problem be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2021-10-05
@ky0

Throw what you currently have in the cron into a bash script and call it in the scheduler, then you won't have to squat with sh -ceverything else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question