Page 1 of 1

SOLVED---Crontab question

PostPosted: Nov 14th, '24, 17:34
by leon244
I reistalled Mageia 9 a few months ago and have been reinstalling my apps. I use luckybackup for doing backups and all has been going well.
I have kernel 6.6.58 installed.
In my prior set up I would set jobs for luckybackup and have luckybackup write to crontab. After that I could simply do a 'crontab -e' and see and edit the crontab file, for example to have it backup twice a month.
Now I was able to set up luckybackup as before and have it write the crontab file, however when I tried to edit it via crontab -e I got an empty file.
I searched for the file and found it under /var/spool/cron/lgoldman. The only way to edit it would be to open an administrator Konsole and then open Kate via that console and then get to the file. Otherwise I cannot open the file.
Is this expected behavior?
Just curious.
Thanks
Leon

Re: Crontab question

PostPosted: Nov 14th, '24, 20:03
by doktor5000
Did you run luckybackup as your user or as root when it wrote the crontab entry initially ?
Per default it should use the current users crontab as per https://luckybackup.sourceforge.net/man ... rontabInfo
Also the files under /var/spool/cron are not mean to be edited directly, but you should get the same content what's in there when you run crontab -e as your user.

Re: Crontab question

PostPosted: Nov 14th, '24, 20:40
by leon244
I set luckybackup as user not root. I also did not edit the file, just wanted to find it

Re: Crontab question

PostPosted: Nov 14th, '24, 21:27
by leon244
FWIW doing as user
Code: Select all
crontab -e
opens a empty file with nothing in it
Doing
Code: Select all
sudo crontab -u $User -e
opens my crontab
In addition
Code: Select all
crontab -l
opens the appropriate file

Re: Crontab question

PostPosted: Nov 14th, '24, 23:32
by doktor5000
leon244 wrote:Doing
Code: Select all
sudo crontab -u $User -e
opens my crontab

It opens it as root. So if you ran sudo luckybackup and set the crontab that way no wonder your regular user does not have permissions to edit it.

crontab -l only lists the content which only needs read access.

Please don't forget to mark the thread as solved, by editing the subject of the first post and prefix it with [SOLVED], thanks in advance.

Re: Crontab question

PostPosted: Nov 14th, '24, 23:41
by leon244
I set up Luckybackup as user not as root. I created the cron within luckybackup as the User not root.. Unless luckybackup creates the user's cron as root, but I don't see how. I am still confused.. When I open LB as the user all the appropriate profiles are there. If I open it as root and the heading says "Super User mode" there are none of the profiles present. This is why I am confused, I did everything as the user not root. For me this issue is not solved. Sorry

Re: Crontab question

PostPosted: Nov 15th, '24, 00:32
by doktor5000
If you did all this as user, why did you try
Code: Select all
sudo crontab -u $User -e

while sudo is not even configured by default ?

The crontab command is setuid by default, and your user is not allowed to the generated crontabs under /var/spool/cron/
The crontab command will generate a temporary file and later write this to /var/spool/cron/- that is why you cannot open that file directly.

You may need to check if your user is listed in /etc/cron.allow if that exists and add your user in there.

Re: Crontab question

PostPosted: Nov 15th, '24, 00:48
by leon244
I tried the -u out of curiosity when -e did not work for me. There is no cron.allow file. I did try to create it and put myself I it but no change. I have written to luckybackup to see what they say. I will also try removing the crontab file and recreate it. But that’s for tomorrow

Re: Crontab question

PostPosted: Nov 15th, '24, 18:53
by leon244
crontab -e appears to be the problem.
crontab -e opens an editor, but the Konsole shows
Code: Select all
[user is lgoldman]$>crontab -e
crontab: no changes made to crontab
and reverts to the command line even though the editor is open
So this time I did 'crontab -e', wrote a line in the editor and saved the file.
When I did crontab -e a second time I got an empty file and the line I had previously added was no where to be found.
I don't know what is happening but LB is working and I will just use it for my backup cron jobs.
I will mark the thread as "Resolved" as I am done with it but the problem is not Solved

Re: Crontab question

PostPosted: Nov 15th, '24, 19:48
by doktor5000
leon244 wrote:crontab -e opens an editor, but the Konsole shows
Code: Select all
[user is lgoldman]$>crontab -e
crontab: no changes made to crontab
and reverts to the command line even though the editor is open
So this time I did 'crontab -e', wrote a line in the editor and saved the file.

crontab -e opens your crontab in what is defined as your editor by the environment variable $EDITOR or $VISUAL
You edit that file in the editor, save it and quit the editor, the resulting file is read by crontab.

Try using a different editor like vim or nano like this:

Code: Select all
EDITOR=vim crontab -e

Re: RESOLVED---Crontab question

PostPosted: Nov 15th, '24, 21:09
by leon244
I’ll try but originally before setting Kate as my editor it was vi and the same thing was happening

Re: SOLVED---Crontab question

PostPosted: Nov 15th, '24, 23:24
by leon244
Doktor, thank you for you perseverence and patience.
Try using a different editor like vim or nano like this:

Code: Select all
EDITOR=vim crontab -e

The short answer is nano or vi work. Kate does not, nor does sublime_text
I tried your code and would point out that the addition of 'crontab -e' at the end made my system unbootable until I went into recovery mode and edited the line out.
I then booted and made nano my editor and it worked as it should .
I then repeated and changed back to Kate and it failed.
I then tried sublime_text and it failed
As it stands it appears that vi, vim, or nano need to be the editor. I have not tried any other editors.
I'm tired and done
Again thank you for your patience and kindness
Leon

Re: SOLVED---Crontab question

PostPosted: Nov 16th, '24, 01:29
by doktor5000
leon244 wrote:I tried your code and would point out that the addition of 'crontab -e' at the end made my system unbootable until I went into recovery mode and edited the line out.

Edit what line out?

Re: SOLVED---Crontab question

PostPosted: Nov 16th, '24, 01:46
by leon244
doktor5000 wrote:Edit what line out?

Had to remove ‘ crontab -e’ from the line and just use ‘EDITOR=vim’
The finally settled on
Code: Select all
EDITOR=nano

Re: SOLVED---Crontab question

PostPosted: Nov 16th, '24, 18:39
by doktor5000
But where did you put that line that you would end up in recovery mode ?

Re: SOLVED---Crontab question

PostPosted: Nov 16th, '24, 19:19
by leon244
Here is what happened.
I put your suggestion
Code: Select all
EDITOR=vim crontab -e
into my .bash_profile replacing the existing EDITOR line
I then rebooted my computer
I got to the login screen, entered my credentials and it began logging in, but immediately hung up and became unresponsive.
I had to manually shut the system down and restart it. At the grub screen I chose the advanced option and then chose to boot into recovery mode for my kernel
In recovery mode I entered as root and the from the command line opened nano and chose my .bash_profile to edit and removed
Code: Select all
crontab -e
from the
Code: Select all
EDITOR=
line and then rebooted. After that the system booted wiithout a problem.
From that point I kept changing the text editor in the "EDITOR=" line and kept logging in and out to see what would work, Nano worked . After my last reply I tried gedit and that works too.
I hope this clarifies events for you

Re: SOLVED---Crontab question

PostPosted: Nov 17th, '24, 18:44
by doktor5000
leon244 wrote:Here is what happened.
I put your suggestion
Code: Select all
EDITOR=vim crontab -e
into my .bash_profile replacing the existing EDITOR line
I then rebooted my computer

crontab -e is an interactive command, why would you put that inside your .bash_rc ?
EDITOR=vim would be sufficient to change the editor.

Re: SOLVED---Crontab question

PostPosted: Nov 17th, '24, 19:10
by leon244
I just exactly copied the line you had written. I thought it was strange but deferred to you. See your reply to me with the code you suggested

Re: SOLVED---Crontab question

PostPosted: Nov 17th, '24, 20:31
by doktor5000
I've never mentioned that you should put that in your .bash_rc, you could have simply asked about that.

Re: SOLVED---Crontab question

PostPosted: Nov 17th, '24, 20:48
by leon244
doktor5000 wrote:
Try using a different editor like vim or nano like this:

Code: Select all
EDITOR=vim crontab -e

This is what you wrote. That all I am saying. No big deal I erred

Re: SOLVED---Crontab question

PostPosted: Nov 17th, '24, 22:49
by doktor5000
Yeah, that's the command to edit your crontab with a different editor. Nowhere does it say "please put this in your .bash_rc".

Re: SOLVED---Crontab question

PostPosted: Nov 18th, '24, 00:43
by leon244
We are going in circles. Let’s just leave it. I made an error.