On 6/22/19 7:05 AM, Antoine Jacoutot wrote: > On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote: >> I've got a shell script I'd like to run as a system service. Due to the >> 16 character limitation on pgrep and the -x flag that rc.subr passes to >> check by default, I can't get check or stop to work correctly. The >> problem is that the process name looks like "/bin/sh >> /usr/local/bin/script.sh" which, even if passed to pgrep, won't match >> when -x is used. >> >> My rc.d script currently looks like this: >> > Hi. > > That should not be an issue, that's why pexp is used for. > But without more context it's hard to know how to help you. > > I can match sh scripts without issue: > $ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session" > 77289 > > Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"? > We don't run into the 16 chars limitation when using -xf
Here's what I was seeing that led me to that conclusion: rukey$ ps aux | grep authmail root 51889 0.0 0.1 724 568 p0- Ip Fri12AM 0:00.01 /bin/sh /usr/local/bin/authmail jacob 25510 0.0 0.2 272 892 p0 S+p 10:36AM 0:00.01 grep authmail rukey$ pgrep -f /bin/sh /usr/local/bin/authmail 51889 rukey$ pgrep -xf /bin/sh /usr/local/bin/authmail However, I didn't think to quote it. that seems to fix it: rukey$ pgrep -xf "/bin/sh /usr/local/bin/authmail" 51889 It appears that rc.subr uses quotes, but: rukey# pgrep -xf "/bin/sh /usr/local/bin/authmail" 51889 rukey# rcctl check authmail authmail(failed) rukey# Any idea what could be going wrong here? Thanks, Jacob