crontab entry with too long line

asked 2018-06-27 04:54:07 -0500

goeldi gravatar image

I want to define this cron resource (command is on 1 line):

cron { 'agents_all':
  ensure  => 'present',
  command => 'php -q /webserver/webroot/htdocs/ > /webserver/scripts/tmp/mylandscapes.log.txt >/dev/null',
  hour    => ['23'],
  minute  => ['0'],
  target  => 'root',
  user    => 'root',

When applying, puppet tells me, that I have to split the line up with \n . So I added two \n, the first after php -q and the second before the >

Now I can apply this without error, but the resulting crontab entry looks like this:

0 23 * * * php -q \n /webserver/webroot/htdocs/ \n > /webserver/scripts/tmp/mylandscapes.log.txt >/dev/null

This crontab entry would not work because of the \n in the command. So, adding \n to long lines in a manifest (as suggested on multiple discussions) seems not to be the correct way. Or did I miss something different?

edit retag flag offensive close merge delete


I'm not 100% sure, but most of what I've found ( ) points to cron not supporting multi-line commands - usually people move the commands into a script and call the script from cron

DarylW gravatar imageDarylW ( 2018-06-27 11:46:02 -0500 )edit