Score:0

is my crontab syntax invalid?

cc flag

simple question:

10 4 * * * rm -rf ~/code/rehlds/build/ && ~/code/rehlds/build.sh --compiler=gcc --jobs=4 > /dev/null 2>&1

I checked an there is no /build folder which indicates that the build.sh did not execute.

crontab -e

10 4 * * * rm -rf ~/code/rehlds/build/ && ~/code/rehlds/build.sh --compiler=gcc --jobs=4 > /dev/null 2>&1

pgrep cron 658 1232359

so here I can see it was run sudo grep CRON /var/log/syslog Dec 8 04:10:01 xxxx CRON[1190963]: (xxx) CMD (rm -rf ~/code/rehlds/build/ && ~/code/rehlds/build.sh --compiler=gcc --jobs=4 > /dev/null 2>&1)

my job ran, but no compiling, that cronlog file is empty.

CMD (./code/rehlds/build.sh --compiler=gcc --jobs=4 &> ./cronlog)

vidarlo avatar
ar flag
Does the logs have any relevant errors?
in flag
With all output redirected to/dev/null there most probably are no logs.
Romeo Ninov avatar
in flag
Set output to log file, not `dev/null` and run again
eetzt avatar
cc flag
`10 4 * * * rm -rf ~/code/rehlds/build/ && ~/code/rehlds/build.sh --compiler=gcc --jobs=4 > ~somelog` like this? will it create this `somelog` if not existing?
Romeo Ninov avatar
in flag
No, use something like: `>/full/path/log 2> /full/path/err` to generate log for STDOUT and for STDERR. And use absolute paths
eetzt avatar
cc flag
not even this works for 5min `* * * * * touch ./testfile &> ./testlog `
eetzt avatar
cc flag
ok now i found out that if you are working with 2 bash sessions and save in nano, then the file is not written, only if you close it...
diya avatar
la flag
Does this answer your question? [Why is my crontab not working, and how can I troubleshoot it?](https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it)
eetzt avatar
cc flag
why does this log output not work? `somecmd > ~/rehldslog 2>&1`. in the logs i can see `(CRON) info (No MTA installed, discarding output) ` and somecmd did not run
Score:0
cc flag
  1. if you work with 2 bash session, you must not only save the file with nano, but close it, only then is the crontab added.

  2. when executing the build.sh I must first cd into that directory otherwise error:

$ ./code/rehlds/build.sh --compiler=gcc --jobs=4 CMake Error: The source directory "/home/cs2" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. make: *** No targets specified and no makefile found. Stop.

I found that out by manually executing this command

correct command:

10 4 * * * cd ./code/rehlds && rm -rf ./build && ./build.sh --compiler=gcc --jobs=4 > /dev/null 2>&1

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.