Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
share|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

1 Answer 1

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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