CRONTAB: control operator in command

Hi,

I want to execute a chain of commands via crontab:
# /usr/local/sbin/zfSnap -a 30d storage/home && halt -p

Right now I only execute a script which holds the chain but I would prefer to have the command directly in the crontab.


How do I do this?

Best Regards,
bsus
 
Put some parentheses around them.

Code:
root@vps-2417-1:~#crontab -l
# minute        hour    monthday        month   weekday         command
0               *       *               *       *               (cd /usr/local/www/awstats/cgi-bin && /usr/bin/perl ./awstats.pl --config=example.com)
 
The parentheses aren't needed, unless you want to background the whole thing with & or send the output of the entire chain to a single file or /dev/null.
 
@DutchDaemon
without them the last command isn't executed

@SirDice
Thank you, will try this later on
 
I have numerous && concatenations in my cron jobs, without parentheses, and they always run to full completion. So I wouldn't know what causes this problem. One example:

Code:
5 0 1 * *	cd /usr/local/share/GeoIP && /usr/bin/fetch http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz && /usr/bin/gunzip -f GeoIP.dat.gz
0 * * * *	/usr/sbin/chown -R www:user /usr/local/www/wordpress && /bin/chmod -R u+rw,g+rw,o+r /usr/local/www/wordpress

Never fail.
 
No, cron is running as the default sh. Tested using an [cmd=]echo $SHELL[/cmd] in the crontab.
 
Back
Top