home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 40.13 Adding crontab Entries Chapter 40
Delayed Execution
Next: 40.15 crontab Script Makes crontab Editing Easier/Safer
 

40.14 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 31st, 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 from O'Reilly & Associates' Essential System Administration


Previous: 40.13 Adding crontab Entries UNIX Power Tools Next: 40.15 crontab Script Makes crontab Editing Easier/Safer
40.13 Adding crontab Entries Book Index 40.15 crontab Script Makes crontab Editing Easier/Safer

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru