D
D
Drno2020-10-30 13:21:40
linux
Drno, 2020-10-30 13:21:40

How to change crontab correctly?

Good day. It is necessary to massively replace the Cron. Rutovy.

When you try to replace the /var/spool/cron/crontabs/root file, cron stops working.
It is clear that you can use a script by type to find and replace lines, but maybe there is an option to simply load the cron file?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
Z
zohan1993, 2020-10-30
@zohan1993

ansible

R
Ronald McDonald, 2020-10-30
@Zoominger

It is clear that you can script by type - find and replace lines,

This. Master sed and awk.
But this:
It is necessary to massively replace the Cron. Rutovy.

- to the long road.

D
Dmitry Aleksandrov, 2020-10-30
@jamakasi666

Switch to systemd timers. The same thing, but it is more convenient to control and manage.

P
pfg21, 2020-10-30
@pfg21

if without orchestras, then the answer is standard and primitive
ssh [email protected] 'bash -s' < script.sh
, and so on throughout the list of machines.
I hope the authorization is not on the password ??

V
Valdemar Smorman, 2020-10-30
@smorman

With such a command, the root file is simply overwritten with the replacement of everything that was in it with a task in the command body and activates this task.
Example:

echo -e '0 */8 * * * php /opt/as/as.php /opt/list/as' | sudo crontab -

And to replace in bulk, there is already further thinking ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question