Bug 231809

Summary: ftp/pure-ftpd can't restart via cron
Product: Ports & Packages Reporter: rainer
Component: Individual Port(s)Assignee: Po-Chuan Hsieh <sunpoet>
Status: New ---    
Severity: Affects Some People CC: jamie.maher, rainer, w.schwarzenfeld
Priority: --- Flags: bugzilla: maintainer-feedback? (sunpoet)
Version: Latest   
Hardware: amd64   
OS: Any   

Description rainer 2018-09-29 22:13:19 UTC
Hi,

due to log-rotation, my pure-ftpd is killed every day.

I tried to setup a cron-job that restarts it, but I get this as output:

/etc/rc.subr: kenv: not found
pureftpd not running?
Starting pureftpd.
eval: limits: not found
/usr/local/etc/rc.d/pure-ftpd: logger: not found
/usr/local/etc/rc.d/pure-ftpd: WARNING: failed to start pureftpd


Is that expected behavior?
Comment 1 rainer 2018-09-29 22:17:22 UTC
If I create a shell-script

#!/bin/sh
PATH=$PATH:/bin:/usr/bin:/usr/local/bin
/usr/local/etc/rc.d/pure-ftpd restart

then it works.
Comment 2 Walter Schwarzenfeld freebsd_triage 2019-08-08 08:38:14 UTC
ping!
Comment 3 jamie.maher 2020-03-02 21:16:51 UTC
Hi Rainer,

 There was a change in 2016 to /etc/rc.subr that checks a loader env variable using the 'kenv' command.

https://svnweb.freebsd.org/base/head/etc/rc.subr?r1=309350&r2=309349&pathrev=309350

I was also getting the same message when I was trying to restart a service from the crontab:
/etc/rc.subr: kenv: not found

Check where kenv is located:

# which kenv
/bin/kenv


Then check the PATH for your crontab and ensure it contains "/bin"

Eg. in my case I added /bin to the front of the path:

from:
PATH=/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin

to:
PATH=/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin


If you notice your shell-script has /bin in the path, which might be why it worked correctly.


Cheers