Fcrontab -r wot?

I was about to recommend a blacklist script and look up exactly how it works, and was about to hammer fcrontab -e into the console and got an immediate

2024-12-03 04:01:42 INFO removing root’s fcrontab
Modifications will be taken into account right now.
[root@maschine # fcrontab -e
2024-12-03 04:02:24 INFO fcrontab : editing root’s fcrontab
no fcrontab for root - using an empty one
Fcrontab is unchanged : no need to install it.

Damn, how do I get all that back?
Is there a way? There has to be a way, right?

In the backup? or not?

That was important, wasn’t it?

No it is not in the backup as it is a core program. Sorry.

Your simplest option is to run the fcrontab -e and then copy the fcrontab contents into it from the git repo content in this link

https://git.ipfire.org/?p=ipfire-2.x.git;a=blob_plain;f=config/cron/crontab;h=7088e0b750a755b860a478b47d6be8809aacd803;hb=refs/heads/next

EDIT:

Actually it looks like there is a way to recover.
In the directory /var/spool/cron/ there should be both a root and root.orig file.

From my understanding of what I have read the root.orig file is the source code that was used to create the binary fcrontab called root.

If you run the command

fcrontab -z

when logged in as root, it should re-install the user that you are logged in as.
From the man page it should also be possible to use

fcrontab -z root

to explicitly tell it to re-install the root user.

EDIT2:

Unfortunately the fcrontab -z doesn’t work because the root and root.orig files are both removed by the fcrontab -r
So the fcrontab -z does not work correctly. I thought it might be for if you have edited some changes and want to revert those changes but I just tested that and that also didn’t work. So not totally sure what fcrontab -z is for.

However what I can confirm is that if you run fcrontab -e and have an empty crontab, if you then past the contents of that url I provided earlier then you end up with a correct fcrontab for root again.

2 Likes