Greetings, Brian Inglis via Cygwin!

> On 2024-07-06 04:50, Andrey Repin via Cygwin wrote:
>> I'm trying to install a new cron job, and the thing fails claiming that it
>> didn't see the edits I made to the file.

>>>> # echo "USER=$USER" | crontab -
>>>>
>>>> # crontab -l
>>>> # DO NOT EDIT THIS FILE - edit the master and reinstall.
>>>> # (- installed on Sat Jul  6 13:35:43 2024)
>>>> # (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie 
>>>> Exp $)
>>>> USER=anrdaemon
>>>>
>>>> # crontab -e
>>>> ### do some edits…
>>>> crontab: no changes made to crontab

> What is your editor, how is it configured, how is it invoked, and how are
> VISUAL and EDITOR defined?

> Most commands that use an editor for some commands effectively invoke 
> ${VISUAL:-${EDITOR:-vi}}.

My $EDITOR is a small wrapper script launching Far manager in editor mode.

>> cygstart "--directory=$( dirname "$1" )" --shownormal --wait -- 
>> "C:\\Programs\\Far3\\Far.exe" -i -co -e0:0 "$( cygpath -alw "${1:-.}" 2> 
>> /dev/null )"

> Your editor also has to behave as if it updates the temporary filename it is 
> invoked with, as from:

>         $ mktemp --tmpdir crontab.XXXXXXXXXX

> for example /tmp/crontab.??????????, save changes into that file, and leave
> it changed when exiting, and other than nano's own /tmp/nano.?????? files, I 
> see no special handling.

> The source has the following note:

>         https://github.com/vixie/cron/blob/master/crontab.c#L389

> which assumes that editors rewrite original files rather than
> renaming/unlinking because that allows security issues, so it compares the
> fstat mtime to the saved value to detect changes.

But that has a potential of losing the file contents.

>> Piping a new file to the crontab works, but that's "slightly" cumbersome.
>> What is it missing why it does not want to just work?
>> -- Few moments later… ---
>> It seems crontab dislikes safe file writes.

> What do you mean by safe file writes?

Hardlink original to temp. name, write to a new file, rename to original,
delete temp. name only if write and rename was successful.
This is a core function in Far's builtin editor and is not configurable.

>>>> $ stat x > 1; nano x; stat x > 2; diff -u0 1 2

>>>> $ stat x > 1; $EDITOR x; stat x > 2; diff -u0 1 2

> What do these show?

That nano rewrites original, where Far does not.

> If you are using `nano`, that should work, as it is used in almost every
> example from RaspberryPi, and someone would have complained!
> Unless the Cygwin package config differs from the Debian config, and it does
> not appear to significantly.

Naay… nano works. Running `EDITOR=nano crontab -e` works around the issue.

>> Is there a way around it that does not involve replacing crontab tool with my
>> own script that has no such issue?

> See above to fix the issue, or use:

>         $ $VISUAL $HOME/$USER.crontab
>         $ crontab $HOME/$USER.crontab
>         $ crontab -l

Figured as much, given the code comment you mentioned above.


-- 
With best regards,
Andrey Repin
Monday, July 8, 2024 01:08:52

Sorry for my terrible english...

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to