Page 1 of 1

crond mysteriously disappeared / stopped running

Posted: Mon Jan 15, 2024 8:44 pm
by Stogie

I'm using Easy Buster64 and have been running some tests with cron, using a text editor on root's crontab file /var/local/cron/crontabs/root and making very simple crontab entries (like echoing a string to a file, or running a script file) just to see if they run correctly and on-time. So far so good, and I'm pleased with how easy it is to do.

One problem however. During my simple tests, just one time, the crond job mysteriously stopped running (disappeared from the ps listing, and scheduled jobs no longer ran at all), and for no apparent reason. I manually restarted crond (typed in a shell "busybox crond -c /var/local/cron/crontabs") and everything worked great again, and has continued to work fine and the job hasn't disappeared again.

This is unsettling to me, though, as I plan to use cron for important jobs on remotely-located EasyOS machines I won't have easy access to. If it happened once, it stands to reason it could happen again, then jobs wouldn't run and I'd have no easy way to restart the crond process.

Any idea why this happened? I took no action to kill the process at all and I did nothing unusual, I was just adding crontab entries and monitoring results.

Thanks guys!


Re: crond mysteriously disappeared / stopped running

Posted: Mon Jan 15, 2024 11:16 pm
by Stogie

.
A few of the tests I did involved using cron to run scripts via the "exec" command, and I also had it run scripts normally but with the script itself using "exec" commands to run other stuff. So I thought maybe one of these killed crond by taking over its process so it ended when the script ended (which is what exec does), but I re-tried that several times and it did NOT end the crond process. So that's probably not the cause.

So I really don't know why crond ended/disappeared. Has anyone had similar experiences? Can anyone recommend what to do, or what NOT to do, to keep it from happening again?

Like I said, it was just the one time, but that's enough to be unsettling and worrisome. Merely scheduling and running cron jobs should NOT kill the crond process!
.


Re: crond mysteriously disappeared / stopped running

Posted: Tue Jan 16, 2024 10:38 am
by BarryK

Maybe using 'restarter' would help. For info:

Code: Select all

# restarter --help

Example of usage:

/etc/init.d/bluetooth


Re: crond mysteriously disappeared / stopped running

Posted: Tue Jan 16, 2024 7:29 pm
by Stogie

.
Thanks Barry! My older EasyOS version doesn't have "restarter" baked-in nor is it available from petget, but the petget search results did include "restartd" and from its documentation, It sounds like it does the same thing, so I successfully installed it. I'm going to experiment with it now.

Thanks for pointing me in the right direction!
.


Re: crond mysteriously disappeared / stopped running

Posted: Tue Jan 16, 2024 10:48 pm
by Stogie

.
Wow, "restartd" is ridiculously simple and effective! I'm impressed. All I did was create the file "/etc/restartd.conf" containing this single line:

Code: Select all

crond ".*busybox crond" "busybox crond -c /var/local/cron/crontabs" ""

then I just typed this in the shell:

Code: Select all

restartd

And that's it! If I kill the "busybox crond" process (or anything else does), within the next 20 seconds "restartd" will notice it's absent and will restart it. Perfect!

Now I just have to start "restartd" automatically upon system startup, and I'm good! Based on the "README.txt" file in /root/Startup all I should have to do is drop a link to "restartd" into the /root/Startup directory, and EasyOS will start it automatically after the X desktop has loaded. That should work fine, and is extremely simple to do!

This package was only 42 KB, if I recall right, the command line options are few, simple and self-explanatory. I love software like this!

I hope this info helps someone!
.


Re: crond mysteriously disappeared / stopped running

Posted: Wed Jan 17, 2024 1:08 pm
by BarryK

I can't remember what version of EasyOS that restarter got introduced. It is builtin. Here is the info:

Code: Select all

# restarter -h

Restarter. (https://bitbucket.org/sivann/restarter)
Usage: restarter [-d] [-h] [-t timeout] [-c command] [-p pid_file]
	-c [command]	command to execute, include arguments in quotes. Mandatory.
	-d		debug
	-s		use a shell to execute command(s)
	-t		timeout: terminate process after timeout seconds
	-l		syslog: redirect command stdout and stderr to syslog
	-m		multiple: keep multiple instances of process running
	-e		valid exit status: comma separated exit status which prevent restart
	-i		syslog ident string
	-p		write pid of new process to pid_file
	-1		start only if process specified by -p is not running

Anyway, good that restartd is doing the job for you.