Monday, 14 November 2022

How to run anaconda in a bash script?

example1:-

export PATH="/home/ninja/anaconda3/bin/:$PATH"
eval "$(conda shell.bash hook)" conda activate vauienv cd /home/ninja/helloworld
pwd python main.py conda deactivate

example2, to include the PID and check every minute in crontab

export PATH="/home/ninja/anaconda3/bin/:$PATH"
eval "$(conda shell.bash hook)"
conda activate triton cd /home/ninja/code TMP="/home/ninja/app.pid" PID="cat $TMP" if ! ps -p $PID > /dev/null then rm $TMP python test.py & echo $! >> $TMP fi conda deactivate 

No comments:

Post a Comment