0

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 username@gmail.com --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 username@gmail.com --auth-mode apikey --password 0ecc3417ad8424ce5eac698092)

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

Daler
  • 283
  • 1
  • 2
  • 7

1 Answers1

0

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.

Tilman
  • 3,599
  • 21
  • 27