I am writing a command in the crontab file

 длинная команда $(date +%Y%m%d%H%M%S) продолжение 

When cron starts execution, it sees only this part.

 длинная команда $(date + 

all that after + he does not see.

How can this be overcome?

    1 answer 1

    according to the documentation ( $ man 5 crontab or online ), the percent symbol % will be converted by cron into a newline character.

    in order to avoid this, add a backsight character in front of each % symbol used:

     ... $(date +\%Y\%m\%d\%H\%M\%S) ... 
    • did as you wrote, but did not help, here’s how cron now sees the command /usr/bin/vlc -vvv rtsp://111.222.333.444:554/h264/ch01/main/av_stream --sout=file/ts:/home/admin/web/site.com/public_html/source/recording-$() - Diefair
    • well, in general, in the original question you had no space between the program name ( date ) and the first argument ( +что-то-там ). probably because the result of the command execution ( $(...) ) doesn’t : there is no such program date+что-то-там - aleksandr barakin
    • if I launch this command simply in the console - everything works - Diefair
    • maybe I'm not doing something. I just need a new unique file name to be generated each time the crown is executed - Diefair
    • all right you do. only a space between the program name and the first parameter / option should be. not a программа параметр , but a программа параметр . not date+\%Y... , but date +\%Y... - aleksandr barakin