Already spent over 1h to make that easy thing and totally failed :/
Cant find why that python not working on crontab while it works perfect in commandline...
Script is (bash):
#!/bin/bash
touch before_zzz_text.txt # to check if cron works at all
ls > "before_zzz_text.txt" # just to check if I'm in the correct directory
/root/anaconda3/bin/python -V > pv.txt # this is empty! or a white char
touch after_zzz_text.txt # this works new file every minute
This way I know it runs in cron (files .txt both created every minute - like cron runs every minute).
However pv.txt is empty ... so looks like bash script not working ?
In the end I want more complicated script to run in the bash script but I tried to dig why it's not working so to simplify it is now "/root/anaconda3/bin/python -V'
/root/anaconda3/bin/python
the python script file? This is confusing, sincepython
is the handler you want to run. Does it start with#!/usr/bin/python
or similar? Does it and all its directory components have execute-all permissions? This is important, as thecrontab
environment is not the same as for your terminal. If the.txt
files were deleted beforehand, what permissions and user / group names were they created with?/root/anaconda3/bin/
is an unlikely location for the interpreter. An empty log file will be produced if an error prevents the interpreter from running. Add2>&1
to the end of thepython
call to see any errors.stderr
: like you, I had assumed it would be onstdout
, but I've just confirmed this on my own system. Glad you're in business. I think I'll submit an answer, for the benefit of other users of the site.