On reading documentation when programs don't work as expected
No matter how often you use UNIX tools, once in a while you get caught out trying to put everything together. This happened this morning while I was setting up a cronjob and it didn't work as expected.
This happened to me earlier this week when I tried to setup a quick cron script to dump the contents of an SQL table every day. I had set it up as follows:
37 3 * * * /usr/lib/postgresql/8.2/bin/pg_dump db -U backup -t table | bzip2 - > /backups/table-monitoring/`date +%Y%m%d`.table.sql.bz2
I checked the next day that things were working and found the directory empty. Interesting.
After a quick check of my email I found the culprit:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"' /bin/sh: -c: line 1: syntax error: unexpected end of file
This is where things got complicated. Had I checked crontab(5) this story would probably have ended here. I didn't.
After a couple of attempts at escaping this command line to make things work I ended up with the following:
backup:~% ls /backups/table-monitoring | head -n 3 `date \+%Y%m%d`.table.sql.bz2 date +%Y%m%d.table.sql.bz2
Even more interesting...
Turns out the answer is quite simple. The man page has this to say about it:
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 % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. There is no way to split a single command line onto multiple lines, like the shell’s trailing "\".
Ooops. A quick change later, I end up with the following snippet:
37 3 * * * /usr/lib/postgresql/8.2/bin/pg_dump db -U backup -t table | bzip2 - > /backups/table-monitoring/`date +\%Y\%m\%d`.table.sql.bz2
I'm still wondering about the usefulness of the % to send data to the standard input as opposed to using standard pipes though.
UXC Connect’s Jesmond Psaila says that DevOps can do for IT operations what Agile did for software development. This paper demonstrates how, by combining both approaches, you can significantly improve operational efficiency and time-to-market. • Marketing and development teams want to constantly change or increase functionality, while IT operations teams want to keep the environment as stable as possible • Agile software development and virtualisation have not solved the time-to-value problem faced by marketing and IT operations teams • Recent movements in DevOps aim to address and redefine a more agile service management platform, while new tools have vastly improved functionality to configure and automate common processes
- CCL2 Technical Support Engineer - RightFax/MessagingVIC
- FTSenior Media TraderNSW
- FTDigital Account Manager X 3 | Display + Video advertisingNSW
- FTCampaign Managers | RTB | Display + Video | Trading desk |SydneyNSW
- FTMachine Learning | JAVA | San Fran based global Company | SydneyNSW
- FTCampaign Managers| RTB / Programmatic | Expression of InterestNSW
- FTChief Information OfficerNSW
TheInfoPro's unique Market Window uses IT professionals ratings of vendors on 14 separate criteria to calculate scores for Vendor Promise and Vendor Fulfillment, allowing comparison of vendors’ effectiveness at strategy, marketing, delivery and execution. In prior studies, this research appeared in the Vendor Performance report.
- Should you buy enterprise applications from a startup?
- Microsoft's Australian Azure region 'just around the corner'
- Healthdirect Australia sees value in open source for security solution
- Namecheap says accounts compromised in hacking incident
- Why hackers may be stealing your credit card numbers for years
- Quickflix suffers $10m loss
- Web Marketing Experts to create 115 new jobs in Melbourne
- Comms Alliance backs website blocking in piracy fight
- Reconnaissance code on industrial software site points to watering hole attack
- China orders Microsoft to explain Windows, Office practices within 20 days
- Europol launches international cybercrime task force
- Show spotlight will be on smartwatches with better looks and connectivity
- China gives Microsoft 20 days to answer questions in anti-monopoly probe
- Happy Labor Day -- will a bot take your help desk job?
- European 700MHz band should be freed for mobile broadband by 2020, report says