delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/07/07/17:10:06

DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 467LA6G73846685
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=GVr4MJiI
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B15F385B505
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1720386605;
bh=+10nvEdQguSYfTsUkPK7tvudbsyGphpoXRNob0pgjow=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=GVr4MJiI6HKrArmVJ/KkTdtXdDDqCtRCaapm4rHFzi/uF9iHoVn2J961M/5CCeQvl
StWV7ei+iuI3MStzJENW4Pu/y7y04b/fglNGTVS1c4ghPTb5vJFfT/DkWnhhmeHyri
zsrTTwSZHQrpqKadODd93eYztFILWkkAOY7Out+g=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8581D385B505
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8581D385B505
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720386582; cv=none;
b=BD9MRCROMS3Ab1Wdrhq8jGDW2NiFdDzuReQ0ZYapPn/9RsLF7cmx+1fV1tvSkpJIG+B40R+ZGhBI9eT+FF8GJMIbPDL8/Nw2mVsqQjM2B9Sir3WrRUmSDrOb7xf5RITCw1NpXXUodnb8WCkVhGhRkBqGDsPOr4Kb0Jj+VHT8LzQ=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1720386582; c=relaxed/simple;
bh=DDVWLX00STai+bgd5TeibaoiSgaMz9Plto6+7O6GeT8=;
h=Message-ID:Date:MIME-Version:Subject:To:From;
b=CnCskP0P3Aj3dhNG/eDSi65qen5vWoOjpKVZj2hyo7trDtEDWH6HiVRL6fGcZ/94vtZ7y6ujT5TswVAw4c/B8SoYagv/5AEGSPYmDcmgZKZ0FKeoTTqOy26GtBlTcKXgAXTY5gXclrPugj2poRjDsXWV1iOIUKQN3s00drsbCkI=
ARC-Authentication-Results: i=1; server2.sourceware.org
Message-ID: <a93617f2-0f4a-47da-b74e-1de4798c2a6d@SystematicSW.ab.ca>
Date: Sun, 7 Jul 2024 15:09:37 -0600
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: crontab: no changes made to crontab
To: cygwin AT cygwin DOT com
References: <1688028774 DOT 20240706135038 AT yandex DOT ru>
Organization: Systematic Software
In-Reply-To: <1688028774.20240706135038@yandex.ru>
X-Stat-Signature: ba7b4x8xxkrjnku58yec3hfh5fd3jjqn
X-Rspamd-Server: rspamout05
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,
SPF_PASS, TXREP,
UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6
X-Rspamd-Queue-Id: 6606720010
X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361
X-Session-ID: U2FsdGVkX1/6JI5M2iT46i3IG/UPLnpS9/AQMJIBmsg=
X-HE-Tag: 1720386578-305269
X-HE-Meta: U2FsdGVkX18Anw0bYxLuST/jdVQAKFPFT6e1ZvxMgpXfhg5kmJdmDlJHOJ8F1QpUquIa5SFX+0imH9l+w5sJiDkyPG6BWA5AUsfWgTCUW2PsSwHGHr6jvxunCZx92u3OrlfLcFHmq8Mt7ZVr6u+BJGyPZsTxN8jS8aKktaV8UX8g353fxz77WAbfgtfIEUax88YAoCwY+m7tHoxMFrbb3nqs85cO9UA8FPHq20aOBEEGgDAymdpbsjd5gMnnbPrpk36CYkESBJEXCUjqEzmhCRHZ+ccGn3S4ITxhs3Nu3jgPfk8Z/jws/DdxRslmOatA9dC8omlp4JWe+UaPsEZxLktZLOjoQ91xrpooTueRpmvYRF9kZnqdlg==
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Brian Inglis via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Brian Inglis <Brian DOT Inglis AT SystematicSW DOT ab DOT ca>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 467LA6G73846685

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}}.

For example, I run gvim under X, it backgrounds, so I have VISUAL='gvim -f' and 
EDITOR=vim so gvim stays in the foreground for crontab, git, etc. and the same 
process and PID is used as forked.
For cygport, it only looks at EDITOR, so in ~/.cygwin_aliases, I have:

	alias cygport="EDITOR=\"$VISUAL\" cygport"

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.

> 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?

>>> $ 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?

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.

> 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

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019