V
V
Victor2014-06-15 18:02:08
linux
Victor, 2014-06-15 18:02:08

How to remove and add jobs to cron from c++ program?

Advise a lib, a piece of code, or something else other than calling linux utilities through the shell.
The tasks are simple: adding, editing, deleting.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Rsa97, 2014-06-15
@Rsa97

crontab is a text file. Open, read, rewrite, close. You only need root rights.

V
Vlad Zhivotnev, 2014-06-16
@inkvizitor68sl

https://stackoverflow.com/questions/11573974/write...

P
Pavel Selivanov, 2014-06-16
@selivanov_pavel

You need root permissions to edit /etc/crontab, which is not good. If for some reason the program still works as root, it is better not to touch this file, but to create separate task files in /etc/cron.d and pull service cron reload.
To run a task as a regular user, you need to call the crontab utility, feeding it a file with tasks. They will be stored in /var/spool/cron/crontabs (depends on the implementation), there is no need to pull the service.

M
maratsh, 2014-06-18
@maratsh

In any case, it is not necessary to pull.
cron uses inotify in /etc/cron.d/ and /var/spool/cron/crontabs to watch for changes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question