Today I was surprised to learn that cron jobs are not run in a shell. That was really a surprise. The reason it shocked me was that I had the following in a crontab:
where I'd written a nice little bash script to send a piped message to our Campfire room, and I wanted to pipe the output of the startQL command to that room so we'd be able to see what happened without having to check our email.
The script takes stdin and sends it on as a pass-through, but with a copy being send to Campfire. It's a pretty nice little script that just uses the Campfire curl API:
What I found was that the pipe wasn't working because we weren't in a real shell. It was easy enough to fix - just put the commands in a new file and call that, or use a subshell:
This entry was posted
on Monday, October 8th, 2012 at 11:30 am and is filed under Coding, Cube Life.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.