S
S
Story teller2022-03-16 11:46:12
ubuntu
Story teller, 2022-03-16 11:46:12

What is the best way to run the program on the server: crontab or systemd?

Which is better, an infinite loop with sleep and unit in systemd or a task in crontab? What are the pros and cons of these approaches?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vindicar, 2022-03-16
@Story teller

Counter questions:
1. Is initialization large at startup? If you need to perform a lot of start-up operations, and expensive ones, then it may make sense to start and sleep.
2. Is the triggering strictly timed or may it be necessary to monitor other events? If absolutely exactly the first, then you can crowns. If the latter is possible (and it's not about "the user himself called the program"), then a daemon is better.
3. Are there any dependencies, i.e. other software that must be running by the time it is triggered? If so, systemd can fix them, EMNIP.

D
Dr. Bacon, 2022-03-16
@bacon

for example, systemd can raise itself if anything, and systemd has its own crontab.

What are the pros and cons of these approaches?
And so, you can understand it yourself by making simple logical reasoning based on the principles of operation of these systems and the requirements for your program.

P
pfg21, 2022-03-16
@pfg21

the endless loop with falling asleep was moved to crontab a long time ago, why do you need to duplicate it in your program??
those. of the options for your bike with an infinite loop and krone - use krone.
the systemd is more powerful and more sophisticated than the crown, while completely replacing it.
If you have systemd, use systemd. no - use cron.
the ranking is about the same.

V
Valdemar Smorman, 2022-03-16
@smorman

There is also Supervisor.
Very flexible in settings, good monitoring, multitasking...
IMHO, for my taste, not inferior to Systemd

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question