Tar crontab not working, while command works on it's own [duplicate]
Clash 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"
cron tar date
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.
add a comment |Â
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"
cron tar date
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 executedate
inside of a cron tab job?
â steeldriver
Aug 23 at 14:51
add a comment |Â
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"
cron tar date
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
cron tar date
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 executedate
inside of a cron tab job?
â steeldriver
Aug 23 at 14:51
add a comment |Â
1
See the answer there that talks about%
in crontabs.
â Jeff Schaller
Aug 23 at 14:49
2
... or How can I executedate
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
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