Project

General

Profile

Bug #25151

Fix cron job "Run now" button

Added by DENNY VANDEMAELE over 1 year ago. Updated about 1 year ago.

Status:
Resolved
Priority:
Nice to have
Assignee:
William Grzybowski
Category:
GUI (new)
Target version:
Seen in:
Severity:
New
Reason for Closing:
Reason for Blocked:
Needs QA:
No
Needs Doc:
Yes
Needs Merging:
Yes
Needs Automation:
No
Support Suite Ticket:
n/a
Hardware Configuration:

Various hardware... 4 physical, 6 virtual

ChangeLog Required:
No

Description

I have several cron jobs that I've run for years that provide email notifications on various aspects of my freenas servers (10 in total).

All the cron jobs run fine unless they are started by the 'Run Now' button in the GUI.

Here is a sample cron job that is run by user root. When run from the commandline, it works perfectly and doesn't get stuck. It also works perfectly if allowed to run on its own.

root@freenas2:/ # /usr/local/bin/upsc ups@localhost | /usr/bin/mail -s "FreeNAS2 UPS Status" root
root@freenas2:/ # ps aux | grep UPS | grep -v grep
root@freenas2:/ #

Now I highlight the cron job in the gui and press the "Run Now" button. I do not receive my email. I check the processes and it's stuck:

root@freenas2:/ # ps aux | grep UPS | grep -v grep
root 62572 0.0 0.0 13136 2740 - S 08:31 0:00.01 /bin/sh -c /usr/local/bin/upsc ups@localhost | /usr/bin/mail -s "FreeNAS2 UPS Status" root > /dev/null 2>&1 | logger -t cronjob
root 62575 0.0 0.0 20972 2560 - S 08:31 0:00.00 /usr/bin/mail -s FreeNAS2 UPS Status root

If I copy the stuck command and paste it into the commandline I get an error that I'm using the upsc command incorrectly (/bin/sh -c doesn't pass the parameters):

root@freenas2:/ # /bin/sh -c /usr/local/bin/upsc ups@localhost | /usr/bin/mail -s "FreeNAS2 UPS Status" root
Error: invalid UPS definition.
Required format: upsname[@hostname[:port]]

Looking at the manpage for 'sh -c' I see the following note:

"The -c option causes the commands to be read from the string operand instead of from the standard input. Keep in mind that this option only accepts a single string as its argument, hence multi-word strings must be quoted."

I copy the stuck command and paste it into the commandline again using quotes and it suceeds:

root@freenas2:/ # /bin/sh -c '/usr/local/bin/upsc ups@localhost | /usr/bin/mail -s "FreeNAS2 UPS Status" root'
root@freenas2:/ #

This is one of many notifications that fail in similar manners. I have notifications to send mail for zpool status, iperfs, etc.


Related issues

Related to FreeNAS - Bug #24759: Fix "Run now" button for Cron Jobs and Rsync TasksResolved2017-06-21
Related to FreeNAS - Bug #24747: Cron Job: FreeNAS kernel: pid 94061 (python3.6), uid 0: exited on signal 6 (core dumped)Closed: Duplicate2017-06-20

Associated revisions

Revision 9a93e72a (diff)
Added by William Grzybowski over 1 year ago

fix(gui): simplify "run now" and use os.popen

subprocess.Popen is too complex with the shell calling causing problems
with pipes, quotes and stdout/stderr.

Ticket: #25151

Revision 1300487b (diff)
Added by William Grzybowski over 1 year ago

fix(gui): simplify "run now" and use os.popen

subprocess.Popen is too complex with the shell calling causing problems
with pipes, quotes and stdout/stderr.

Ticket: #25151

History

#1 Updated by Dru Lavigne over 1 year ago

  • Status changed from Unscreened to Closed: Duplicate

Denny: this will be fixed in U3 (due out in a few weeks). See the related bug for details.

#2 Updated by Dru Lavigne over 1 year ago

  • Related to Bug #24759: Fix "Run now" button for Cron Jobs and Rsync Tasks added

#3 Updated by DENNY VANDEMAELE over 1 year ago

Thanks. I read this prior to submitting mine, but since my bug isn't throwing permission errors, and can be fixed by adding quotes, I thought it was different.

#4 Updated by Dru Lavigne over 1 year ago

  • Status changed from Closed: Duplicate to Unscreened
  • Assignee changed from Release Council to William Grzybowski

William: can you double-check if this is a separate or related issue?

#5 Updated by William Grzybowski over 1 year ago

  • Status changed from Unscreened to Screened
  • Priority changed from No priority to Nice to have
  • Target version set to 11.1

This is a different issue.

#6 Updated by William Grzybowski over 1 year ago

  • Status changed from Screened to Ready For Release

#7 Updated by Dru Lavigne over 1 year ago

  • Related to Bug #24747: Cron Job: FreeNAS kernel: pid 94061 (python3.6), uid 0: exited on signal 6 (core dumped) added

#8 Updated by Dru Lavigne over 1 year ago

  • Subject changed from cron job quits working (and hangs) using the run now button after upgrade from 9.10 to 11.0-U1 to Fix cron job "Run now" button

#9 Updated by Dru Lavigne about 1 year ago

  • Target version changed from 11.1 to 11.1-BETA1

#10 Updated by Bonnie Follweiler about 1 year ago

  • Needs QA changed from Yes to No
  • QA Status Test Passes FreeNAS added
  • QA Status deleted (Not Tested)

Test passed in FreeNAS-11-MASTER-201710180506

#11 Updated by Dru Lavigne about 1 year ago

  • Status changed from Ready For Release to Resolved

Also available in: Atom PDF