## 25.4. Including Standard Input Within a cron Entry

Since crontab entries must be a single line long, it's hard to include any standard input with them. Sure, you can use commands like:

>     0 22 * * * echo "It's 10PM; do you know where your children are?" | wall

but you can't use "here documents" and other methods of generating multiline input; they intrinsically take several lines.

To solve this problem, cron allows you to include standard input directly on the command line. If the command contains a percent sign (`%`), cron uses any text following the sign as standard input for cmd. Additional percent signs can be used to subdivide this text into lines. For example, the following crontab entry:

>     30 11 31 12 * /etc/wall%Happy New Year!%Let's make next year great!

runs the wall command at 11:30 a.m. on December 31, using the text:

>     Happy New Year!
>     Let's make next year great!

as standard input. [If you need a literal percent sign in your entry, for a command like `date +%a`, escape the percent sign with a backslash: `\%`. -- JP]

-- AF

Copyright © 2003 O'Reilly & Associates. All rights reserved.