Trying to add this to the crontab (Ubuntu):

0 2 * * * /usr/local/sbin/aws dsnap | grep vol-193vja9 | sort -r -k 5  | sed 1,5d | awk '{print "Deleting snapshot: " $2 " Dated:" $8}; system("/usr/local/sbin/aws delsnap " $2 )'  >>  /var/backup.log  2>&1

However, I'm getting an error that says:

0: command not found
link|improve this question

1  
Just to be clear, is that the actual command line you are trying to run? – John Gardeniers Oct 3 '11 at 0:58
feedback

1 Answer

up vote 3 down vote accepted

I could be wrong, but it looks like you are trying to execute the whole crontab job, including the crontab times.

Try adding your crontab job with this:

echo "0 2 * * * /usr/local/sbin/aws dsnap | grep vol-193vja9 | sort -r -k 5  | sed 1,5d | awk '{print "Deleting snapshot: " $2 " Dated:" $8}; system("/usr/local/sbin/aws delsnap " $2 )'  >>  /var/backup.log  2>&1" | crontab -

However, it would probably be easier for you to just edit the crontab like so:

crontab -e 

and then paste the line into the screen manually.

Either way, you can verify that its been added by typing:

[rilindo@kvm0007 ~]$ crontab -l
0 2 * * * /usr/local/sbin/aws dsnap | grep vol-193vja9 | sort -r -k 5  | sed 1,5d | awk '{print Deleting snapshot:    Dated: }; system(/usr/local/sbin/aws delsnap   )'  >>  /var/backup.log  2>&1
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.