Score:0

Cron task does not get executed

br flag

I have a list of commands to run every day. When I copy paste it directly to terminal and run it is working but when I copy paste the same command to cron its not working.

This is the command

0 10 * * * commcare-export --query /home/administrator/Documents/commCareExcelFiles/case_data/1.xlsx --project projectX --output-format sql --output postgresql://user:pass12345@localhost:5432/dbname --username [email protected] --auth-mode apikey --password 0ecc3417ad8424ce5eac698092

I can see in cron logs the following

(administrator) CMD ( commcare-export --query/home/administrator/Documents/commCareExcelFiles/case_data/1.xlsx --project projectX --output-format sql --output postgresql://user:pass12345@localhost:5432/dbname --username [email protected] --auth-mode apikey --password 0ecc3417ad8424ce5eac698092)

But when I check the database there are no new records, unless it's ran directly from terminal. L

in flag
You will need to specify the full path for `commcare-export`, as the cron job will not know where to look for that tool.
br flag
@matigo added absolute path too but still no result
bac0n avatar
cn flag
You should migrate to systemd.timer.
Score:0
cn flag

Twofold answer:

a) Check your local mailbox. If a cronjob encounters an error (more precisely: if it produces any output at all on stdout or stderr) it sends it via mail to the local root account which should be forwarded to your personal mail account. (If it isn't then you should fix that.)

b) Enter the absolute path for the command commcare-export in your crontab entry. cron does not inherit your PATH setting. It only looks for command binaries in the standard locations /bin and /usr/bin. The command commcare-export is not a standard Ubuntu command. It is not unlikely that its binary resides in some software specific folder. To find out its absolute path if you don't know it, enter the command which commcare-export in a terminal where the command commcare-export is working.

br flag
I got the absolute path. It says `/usr/local/bin/commcare-export` I update my cron task but still no result
Tilman avatar
cn flag
So what does the mail say?
br flag
i was trying to schedule a cron task for python package. Adding the path for python and after that commcare-export did the trick.
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.