Search code examples
pythonlinuxcommand-linecron

Python3 script runs fine in console but won't work while executed by crontab


I'm trying to get the following script to run successfull on crontab but it won't work.

*/3 * * * * /usr/bin/python3 /var/www/secret_directory/main.py > /home/USER/grabber.log

I tried to just run the command in SSH and it worked:

/usr/bin/python3 /var/www/secret_directory/main.py

If it works the outputs should look like this:

100%|██████████████████████████████████████████████████████████████████████████████| 61/61 [00:16<00:00,  3.62it/s]
100%|██████████████████████████████████████████████████████████████████████████| 1696/1696 [01:09<00:00, 24.30it/s]

but it looks like this in the grabber.log file:

  0%|          | 0/1 [00:00<?, ?it/s]
100%|██████████| 1/1 [00:00<00:00,  3.60it/s]
100%|██████████| 1/1 [00:00<00:00,  3.59it/s]

I don't know if it is important but it is about this software: https://github.com/RedBlaze42/Mars2020-images-downloader

Thanks for your help!


Solution

  • Just take out the calls to tqdm; replace anything whict looks like tqdm(whatever) with just whatever.

    https://tqdm.github.io/ is a library for displaying "friendly" progress meters, but that's obviously only useful for interactive programs, and problematic when you want to run the code in a place where there is no terminal.