C
C
cyberlog2016-09-25 17:19:29
ubuntu
cyberlog, 2016-09-25 17:19:29

Variable assignment not working in cron?

OC - ​​ubuntu
has a script of banal content - creates files in the name of which the date of creation is present
-----------------------
#!/bin/ bash
date=`date '+%d%m%y_%H.%M.%S'`
*/1 * * * * echo "123" > /vagrant/crontab/$date.txt
------ -----------------------
script creates file: `date '+%d%m%y_%H.%M.%S'`.txt
though if you run the following commands in the console:
$ date=`date '+%d%m%y_%H.%M.%S'`
$ echo "123" > /vagrant/crontab/$date.txt
then the expected date file is created in the name.
what could be the snag?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2016-09-27
@click0

bash cannot interpret this command -
*/1 * * * * echo "123" > /vagrant/crontab/$date.txt
take away
*/one * * * *and everything will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question