Project

General

Profile

Actions

Bug #32859

closed

foreman 2.5 /etc/cron.d/foreman broken

Added by Gerald Vogt almost 3 years ago. Updated about 2 years ago.


Description

See also here: here

The foreman crontab in /etc/cron.d/foreman changed to include a timestamp to the output, e.g.

*/30 * * * *    foreman    /usr/sbin/foreman-rake ldap:refresh_usergroups | gawk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0 }' >>/var/log/foreman/cron.log 2>&1

instead of
*/30 * * * *    foreman    /usr/sbin/foreman-rake ldap:refresh_usergroups >>/var/log/foreman/cron.log 2>&1

However, there are two problems here:

1. The percent sign % has special meaning in a crontab file and is replaced with a newline and the remainder is sent as standard input.

From crontab(5):

The "sixth" field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or a "%" character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. A "%" character in the command, unless escaped with a backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

2. The redirection only applies to the second command not the pipe as a whole. This means that standard error output of the rake command now is sent to standard error and it not redirected. It ends up in a cron mail instead of cron.log.

Correct would be:

*/30 * * * *    foreman    /usr/sbin/foreman-rake ldap:refresh_usergroups 2>&1 | gawk '{ print strftime("[\%Y-\%m-\%d \%H:\%M:\%S]"), $0 }' >>/var/log/foreman/cron.log 2>&1

or
*/30 * * * *    foreman    /usr/sbin/foreman-rake ldap:refresh_usergroups |& gawk '{ print strftime("[\%Y-\%m-\%d \%H:\%M:\%S]"), $0 }' >>/var/log/foreman/cron.log 2>&1

Actions #1

Updated by Ewoud Kohl van Wijngaarden almost 3 years ago

  • Target version set to 2.5.1
Actions #2

Updated by The Foreman Bot almost 3 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Evgeni Golov
  • Pull request https://github.com/theforeman/foreman-packaging/pull/6817 added
Actions #3

Updated by The Foreman Bot almost 3 years ago

  • Pull request https://github.com/theforeman/foreman-packaging/pull/6818 added
Actions #4

Updated by The Foreman Bot almost 3 years ago

  • Fixed in Releases 3.0.0 added
Actions #5

Updated by The Foreman Bot almost 3 years ago

  • Pull request https://github.com/theforeman/foreman-packaging/pull/6820 added
Actions #6

Updated by The Foreman Bot almost 3 years ago

  • Pull request https://github.com/theforeman/foreman-packaging/pull/6822 added
Actions #7

Updated by Evgeni Golov almost 3 years ago

  • Status changed from Ready For Testing to Closed
Actions #8

Updated by Evgeni Golov almost 3 years ago

  • Assignee deleted (Evgeni Golov)
  • Target version deleted (2.5.1)
  • Fixed in Releases 2.5.1 added
  • Fixed in Releases deleted (3.0.0)
Actions #9

Updated by The Foreman Bot about 2 years ago

  • Pull request https://github.com/theforeman/foreman-packaging/pull/7749 added
Actions #10

Updated by Ewoud Kohl van Wijngaarden about 2 years ago

  • Pull request deleted (https://github.com/theforeman/foreman-packaging/pull/7749)
Actions

Also available in: Atom PDF