I am trying to make a
crontab that makes a new
.tar file each minute every business day by using the following code:
*/1 * * * 1,2,3,4,5 tar -cf /home/user/Archiv/$(date +"%Y%m%d%H%M").tar /home/user/Textverarbeitung/ -P
This doesn't work. Why?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
% as newlines. You need to use escape it i.e. use
\% to get literal
% as used in
So you need:
Or you can use a script and use all the commands in the script and call the script from
man 5 crontab:
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. There is no way to split a single command line onto multiple lines, like the shell's trailing "\".