NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/58408: cron ignores parameter "-n" in crontab



The following reply was made to PR bin/58408; it has been noted by GNATS.

From: "Dr. Nicola Mingotti" <nmingotti%gmail.com@localhost>
To: gnats-bugs%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/58408: cron ignores parameter "-n" in crontab
Date: Mon, 22 Jul 2024 17:36:45 +0200

 Hi Christos, thanks for looking into it,
 
 I hope i am doing well replying to the email.
 
 To ease the reproduction of the problem I re-do it all in a VM.
 
 . I get an image from https://nycdn.netbsd.org/pub/arm/,
    download the image NetBSD 10.0, GENERIC 64 bit, decompress,
    change its size do 2G (required by qemu), rename to arm64.img
    for shorter command lines.
 
 . I run it in qemu in Linux/Debian with
 $> qemu-system-aarch64 -M virt -cpu cortex-a53 -smp 4 -m 4g -drive 
 if=none,file=/home/p/download/arm64.img,id=hd0 -device virtio-blk-devic
 e,drive=hd0 -netdev type=user,id=net0 -device 
 virtio-net-device,netdev=net0,mac=00:11:22:33:44:55 -bios 
 /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -
 nographic
 
 . login as root
 
 . Create the user "p" and its directory
 
 . #> su p    ( i don't set password, this is a test machine)
 
 . Create the file /home/p/test3.sh and /home/p/test4.sh
    code given previously, make them executable
 
 . Create the empty file /home/p/test.log
 
 . Create crontab
 -----
 # SHELL=/bin/sh
 # MAILTO=p
 #
 # minute hour    mday    month   wday    command
 */1     *       *       *       *       -n /home/p/test3.sh
 */1     *       *       *       *       -n /home/p/test4.sh
 -----
 
 . I can't say if the first 2 lines are relevant, they shouldn't, i guess
 
 . Reboot
 
 . Wait a bit (say 10/20 mins), the errors does not appear immediately, 
 still some
    clues are visible things are not going well
 
 . Some sendmail "zombie"? processes will start to accumulate, probably 
 this is
    related to issue. I guess any of these entries are related to the launch
    of a /home/p/test3.sh command
 $> ps aux | grep mail
 ps aux | grep mail
 p        385  0.0  0.1 22704  5376 ?      Is    4:54PM 0:00.54 sendmail 
 -FCronD
 p        414  0.0  0.1 22708  5380 ?      Is    4:56PM 0:00.36 sendmail 
 -FCronD
 p        808  0.0  0.1 22708  5384 ?      Is    4:57PM 0:00.44 sendmail 
 -FCronD
 p       1621  0.0  0.1 22708  5388 ?      Is    4:42PM 0:00.41 sendmail 
 -FCronD
 p       1720  0.0  0.1 22708  5392 ?      Is    4:43PM 0:00.37 sendmail 
 -FCronD
 ....
 
 . Afte a while some wrong mail will start to appear
    when 2 mail arrive in the same minute it is a good signal
    one of the two is about "test3.sh", so it should not be there.
 $> mail
 ----
   U  5 root@arm64.localdoma  Mon Jul 22 16:49   4/700   "Cron <p@arm64> 
 /home/p/t
 U  6 root@arm64.localdoma  Mon Jul 22 17:04   4/700   "Cron <p@arm64> 
 /home/p/t
 U  7 root@arm64.localdoma  Mon Jul 22 17:05   4/700   "Cron <p@arm64> 
 /home/p/t
 U  8 root@arm64.localdoma  Mon Jul 22 17:06   4/700   "Cron <p@arm64> 
 /home/p/t
 *** >N  9 root@arm64.localdoma  Mon Jul 22 17:07   3/690 "Cron <p@arm64> 
 /home/p/t
 *** N 10 root@arm64.localdoma  Mon Jul 22 17:07   3/689   "Cron 
 <p@arm64> /home/p/t
 N 11 root@arm64.localdoma  Mon Jul 22 17:08   3/690   "Cron <p@arm64> 
 /home/p/t
 ----
 
 . Indeed, opening mail (10) i get
 ---- mail-10 ----------------
 Message 10:
  From p@arm64.localdomain  Mon Jul 22 17:07:03 2024
 X-Original-To: p
 Delivered-To: p@arm64.localdomain
 From: root@arm64.localdomain (Cron Daemon)
 To: p@arm64.localdomain
 Subject: Cron <p@arm64> /home/p/test3.sh
 Auto-Submitted: auto-generated
 X-Cron-Env: <SHELL=/bin/sh>
 X-Cron-Env: <HOME=/home/p>
 X-Cron-Env: <PATH=/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin>
 X-Cron-Env: <LOGNAME=p>
 X-Cron-Env: <USER=p>
 Date: Mon, 22 Jul 2024 17:07:03 +0200 (CEST)
 
 test3: write something and quit.
 --------------------------------------
 
 . This mail should have never arrived, test3.sh does not generate errors
 
 ==================================
 === Requested test =====
 ==================================
 
 . I stop cron
 #> /etc/rc.d/cron stop
 
 . I re-run cron as requested
 #> /usr/sbin/cron -x proc
 debug flags enabled: proc
 [2490] cron started
 [2490] do_command(/home/p/test4.sh , (p,1000,100))
 [2490] main process returning to work
 [2490] do_command(/home/p/test3.sh, (p,1000,100))
 [2490] main process returning to work
 [3145] child_process('/home/p/test4.sh ')
 [3274] child_process('/home/p/test3.sh')
 [839] grandchild process vfork()'ed
 [840] grandchild process vfork()'ed
 log_it: (p 839) CMD START (/home/p/test4.sh )
 log_it: (p 840) CMD START (/home/p/test3.sh)
 [3145] child continues, closing pipes
 [3274] child continues, closing pipes
 [3274] child reading output from grandchild
 [3145] child reading output from grandchild
 [3274] got data (74:t) from grandchild
 [3145] got data (74:t) from grandchild
 [3274] aborting pipe to mail
 [3145] closing pipe to mail
 [2490] sigchld...pid #3274 died, stat=0
 [2490] sigchld...no dead kids
 [3145] got EOF from grandchild
 log_it: (p 3145) CMD FINISH (/home/p/test4.sh )
 [3145] child process done (rc=0), exiting
 [2490] sigchld...pid #3145 died, stat=0
 [2490] sigchld...no children
 ....
 ================================
 
 
 Bye
 Nicola
 
 
 On Sun-21-Jul-2024 21:50, Christos Zoulas wrote:
 > The following reply was made to PR bin/58408; it has been noted by GNATS.
 >
 > From: Christos Zoulas <christos%zoulas.com@localhost>
 > To: gnats-bugs%netbsd.org@localhost
 > Cc: gnats-admin%netbsd.org@localhost,
 >   netbsd-bugs%netbsd.org@localhost
 > Subject: Re: bin/58408: cron ignores parameter "-n" in crontab
 > Date: Sun, 21 Jul 2024 15:45:07 -0400
 >
 >   I just tried your example and it worked as expected
 >   
 >   log_it: (christos 5384) CMD START (/u/christos/cron1)
 >   log_it: (christos 15992) CMD START (/u/christos/cron2)
 >   [4179] child continues, closing pipes
 >   [4179] child reading output from grandchild
 >   [13945] child continues, closing pipes
 >   [13945] child reading output from grandchild
 >   [7886] child continues, closing pipes
 >   [7886] child reading output from grandchild
 >   [4179] got EOF from grandchild [0]
 >   log_it: (christos 4179) CMD FINISH (/usr/bin/true)
 >   [4179] child process done (rc=3D0), exiting
 >   [20135] sigchld...pid #4179 died, stat=3D0
 >   [20135] sigchld...no dead kids
 >   [7886] got data (77:w) from grandchild
 >   [7886] aborting pipe to mail
 >   [13945] got data (77:w) from grandchild
 >   [13945] closing pipe to mail
 >   [13945] got EOF from grandchild [0]
 >   log_it: (christos 13945) CMD FINISH (/u/christos/cron2)
 >   [13945] child process done (rc=3D0), exiting
 >   [20135] sigchld...pid #13945 died, stat=3D0
 >   [20135] sigchld...no dead kids
 >   
 >   you can try running cron -x proc
 >   
 >   
 >   christos
 >   
 >   > On Jul 9, 2024, at 3:35=E2=80=AFAM, nmingotti%gmail.com@localhost wrote:
 >   >=20
 >   >> Number:         58408
 >   >> Category:       bin
 >   >> Synopsis:       cron ignores parameter "-n" in crontab
 >   >> Confidential:   no
 >   >> Severity:       non-critical
 >   >> Priority:       medium
 >   >> Responsible:    bin-bug-people
 >   >> State:          open
 >   >> Class:          sw-bug
 >   >> Submitter-Id:   net
 >   >> Arrival-Date:   Tue Jul 09 07:35:00 +0000 2024
 >   >> Originator:     Dr. Nicola Mingotti
 >   >> Release:        10.0
 >   >> Organization:
 >   > Borghi SRL
 >   >> Environment:
 >   > NetBSD pulce4 10.0 NetBSD 10.0 (GENERIC) #0: Thu Mar 28 08:33:33 UTC =
 >   2024  =
 >   mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/evbarm/compile/GENERIC =
 >   evbarm
 >   >=20
 >   >> Description:
 >   > According to man page crontab (5), if the modifier '-n' is used before =
 >   a command no mail should be sent on successful run. This is not the =
 >   case, parameter '-n' is ignored. Example below.=20
 >   >=20
 >   >=20
 >   >=20
 >   >=20
 >   >> How-To-Repeat:
 >   >=20
 >   > ---- /home/p/bin/test3.sh ----------
 >   > #!/bin/sh
 >   > echo "test3.sh -- `date` " >> /home/p/bin/test.log
 >   > echo "write something and quit. "
 >   > exit 0
 >   > ------------------------------------
 >   >=20
 >   > ---- /home/p/bin/test4.sh ----------
 >   > #!/bin/sh
 >   > echo "test4.sh -- `date` " >> /home/p/bin/test.log
 >   > echo "write something and fail"
 >   > exit 1
 >   > ------------------------------------
 >   >=20
 >   > p@pulce4 $> crontab -l=20
 >   > -----------
 >   > #
 >   > #minute hour    mday    month   wday    command
 >   > */1     *       *       *       *        -n /home/p/bin/test3.sh
 >   > */1     *       *       *       *        -n /home/p/bin/test4.sh
 >   > -----------
 >   >=20
 >   > . wait a bit
 >   > p@pulce4> mail=20
 >   > ----
 >   > N 14 root@pulce4.localdom  Tue Jul  9 08:55   3/695   "Cron <p@pulce4> =
 >   /home/p/bin/test3.sh"
 >   > N 15 root@pulce4.localdom  Tue Jul  9 08:56   3/693   "Cron <p@pulce4> =
 >   /home/p/bin/test4.sh"
 >   > N 16 root@pulce4.localdom  Tue Jul  9 08:56   3/695   "Cron <p@pulce4> =
 >   /home/p/bin/test3.sh"
 >   > N 17 root@pulce4.localdom  Tue Jul  9 08:57   3/693   "Cron <p@pulce4> =
 >   /home/p/bin/test4.sh"
 >   > N 18 root@pulce4.localdom  Tue Jul  9 08:57   3/695   "Cron <p@pulce4> =
 >   /home/p/bin/test3.sh"
 >   > N 19 root@pulce4.localdom  Tue Jul  9 08:58   3/693   "Cron <p@pulce4> =
 >   /home/p/bin/test4.sh"
 >   > N 20 root@pulce4.localdom  Tue Jul  9 08:58   3/695   "Cron <p@pulce4> =
 >   /home/p/bin/test3.sh"
 >   > N 21 root@pulce4.localdom  Tue Jul  9 08:59   3/693   "Cron <p@pulce4> =
 >   /home/p/bin/test4.sh"
 >   > N 22 root@pulce4.localdom  Tue Jul  9 08:59   3/695   "Cron <p@pulce4> =
 >   /home/p/bin/test3.sh"
 >   > ----
 >   >=20
 >   >=20
 >   >=20
 >   >=20
 >   >=20
 >   >=20
 >   >> Fix:
 >   >=20
 >   
 



Home | Main Index | Thread Index | Old Index