rdh61 wrote: ⤴Tue Dec 07, 2021 5:53 pm
Thank you, that worked, but I am afraid I have no idea what it means to run a command "in the shell" or to "run the shell when the command is not run in the shell".
Please could you tell me then what is wrong with the real script I want to run? It is this:
Code: Select all
0 8 * * * /opt/FreeFileSync/FreeFileSync '/home/robert/BatchRun.ffs_batch'
Many thanks.
I think the line should be amended to
Code: Select all
0 8 * * * /bin/sh -c 'echo "FreeFileSync started on $(date)" > /home/robert/FreeFileSync_last_started_on.txt ; /opt/FreeFileSync/FreeFileSync "/home/robert/BatchRun.ffs_batch"'
This also creates a text file named FreeFileSync_last_started_on.txt in your home directory.
Before adding to crontab, please verify this works by running it in a Terminal.
"Without a shell" means that the program is run using its executable (binary / script) + arguments only (not using a shell).
eg. system calls from the exec() family in C/C++, QProcess::start() etc.,
"With a shell" means to run a command in the shell ( /bin/sh for most POSIX systems).
eg. system() call in C/C++, the Terminal app (ie. x-terminal-emulator), the TTY shell etc.,