Tar crontab not working, while command works on it's own [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite













This question already has an answer here:



  • What's wrong with these two cron jobs?

    3 answers



I have this crontab



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant



It does not work. But if I do



tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant/



It works.



Anybody have a clue what's going on? I do keep getting a mail though:



N 10 (Cron Daemon) Thu Aug 23 10:43 28/1130 "Cron <root@localhost> tar -czf"










share|improve this question















marked as duplicate by Jeff Schaller, roaima, Community♦ Aug 23 at 15:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    See the answer there that talks about % in crontabs.
    – Jeff Schaller
    Aug 23 at 14:49






  • 2




    ... or How can I execute date inside of a cron tab job?
    – steeldriver
    Aug 23 at 14:51














up vote
0
down vote

favorite













This question already has an answer here:



  • What's wrong with these two cron jobs?

    3 answers



I have this crontab



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant



It does not work. But if I do



tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant/



It works.



Anybody have a clue what's going on? I do keep getting a mail though:



N 10 (Cron Daemon) Thu Aug 23 10:43 28/1130 "Cron <root@localhost> tar -czf"










share|improve this question















marked as duplicate by Jeff Schaller, roaima, Community♦ Aug 23 at 15:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    See the answer there that talks about % in crontabs.
    – Jeff Schaller
    Aug 23 at 14:49






  • 2




    ... or How can I execute date inside of a cron tab job?
    – steeldriver
    Aug 23 at 14:51












up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:



  • What's wrong with these two cron jobs?

    3 answers



I have this crontab



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant



It does not work. But if I do



tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant/



It works.



Anybody have a clue what's going on? I do keep getting a mail though:



N 10 (Cron Daemon) Thu Aug 23 10:43 28/1130 "Cron <root@localhost> tar -czf"










share|improve this question
















This question already has an answer here:



  • What's wrong with these two cron jobs?

    3 answers



I have this crontab



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant



It does not work. But if I do



tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant/



It works.



Anybody have a clue what's going on? I do keep getting a mail though:



N 10 (Cron Daemon) Thu Aug 23 10:43 28/1130 "Cron <root@localhost> tar -czf"





This question already has an answer here:



  • What's wrong with these two cron jobs?

    3 answers







cron tar date






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 23 at 14:51









Jeff Schaller

32.7k849110




32.7k849110










asked Aug 23 at 14:44









iamAguest

985




985




marked as duplicate by Jeff Schaller, roaima, Community♦ Aug 23 at 15:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Jeff Schaller, roaima, Community♦ Aug 23 at 15:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1




    See the answer there that talks about % in crontabs.
    – Jeff Schaller
    Aug 23 at 14:49






  • 2




    ... or How can I execute date inside of a cron tab job?
    – steeldriver
    Aug 23 at 14:51












  • 1




    See the answer there that talks about % in crontabs.
    – Jeff Schaller
    Aug 23 at 14:49






  • 2




    ... or How can I execute date inside of a cron tab job?
    – steeldriver
    Aug 23 at 14:51







1




1




See the answer there that talks about % in crontabs.
– Jeff Schaller
Aug 23 at 14:49




See the answer there that talks about % in crontabs.
– Jeff Schaller
Aug 23 at 14:49




2




2




... or How can I execute date inside of a cron tab job?
– steeldriver
Aug 23 at 14:51




... or How can I execute date inside of a cron tab job?
– steeldriver
Aug 23 at 14:51










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Your problem is likely because of the cron special treatment of percent sign:




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.




So you need to escape them:



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant





share|improve this answer




















  • Would it be bad if I changed the shell that crontab uses into /bin/bash? Would I break anything?
    – iamAguest
    Aug 23 at 14:58










  • It would only affect you particular crontab, so it should be fairly safe. Of course you would still need to escape percent signs, as those are processed before the command line is handed out to shell (whatever that shell may be).
    – weirdan
    Aug 23 at 15:00

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Your problem is likely because of the cron special treatment of percent sign:




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.




So you need to escape them:



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant





share|improve this answer




















  • Would it be bad if I changed the shell that crontab uses into /bin/bash? Would I break anything?
    – iamAguest
    Aug 23 at 14:58










  • It would only affect you particular crontab, so it should be fairly safe. Of course you would still need to escape percent signs, as those are processed before the command line is handed out to shell (whatever that shell may be).
    – weirdan
    Aug 23 at 15:00














up vote
1
down vote



accepted










Your problem is likely because of the cron special treatment of percent sign:




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.




So you need to escape them:



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant





share|improve this answer




















  • Would it be bad if I changed the shell that crontab uses into /bin/bash? Would I break anything?
    – iamAguest
    Aug 23 at 14:58










  • It would only affect you particular crontab, so it should be fairly safe. Of course you would still need to escape percent signs, as those are processed before the command line is handed out to shell (whatever that shell may be).
    – weirdan
    Aug 23 at 15:00












up vote
1
down vote



accepted







up vote
1
down vote



accepted






Your problem is likely because of the cron special treatment of percent sign:




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.




So you need to escape them:



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant





share|improve this answer












Your problem is likely because of the cron special treatment of percent sign:




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.




So you need to escape them:



* * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant






share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 23 at 14:51









weirdan

48145




48145











  • Would it be bad if I changed the shell that crontab uses into /bin/bash? Would I break anything?
    – iamAguest
    Aug 23 at 14:58










  • It would only affect you particular crontab, so it should be fairly safe. Of course you would still need to escape percent signs, as those are processed before the command line is handed out to shell (whatever that shell may be).
    – weirdan
    Aug 23 at 15:00
















  • Would it be bad if I changed the shell that crontab uses into /bin/bash? Would I break anything?
    – iamAguest
    Aug 23 at 14:58










  • It would only affect you particular crontab, so it should be fairly safe. Of course you would still need to escape percent signs, as those are processed before the command line is handed out to shell (whatever that shell may be).
    – weirdan
    Aug 23 at 15:00















Would it be bad if I changed the shell that crontab uses into /bin/bash? Would I break anything?
– iamAguest
Aug 23 at 14:58




Would it be bad if I changed the shell that crontab uses into /bin/bash? Would I break anything?
– iamAguest
Aug 23 at 14:58












It would only affect you particular crontab, so it should be fairly safe. Of course you would still need to escape percent signs, as those are processed before the command line is handed out to shell (whatever that shell may be).
– weirdan
Aug 23 at 15:00




It would only affect you particular crontab, so it should be fairly safe. Of course you would still need to escape percent signs, as those are processed before the command line is handed out to shell (whatever that shell may be).
– weirdan
Aug 23 at 15:00


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay