Search code examples
pythonlinuxbashubuntucron

How to launch sh script with crontab?


I have sh script that works perfectly if you launch it by yourself. But when I try to put it to the crontab nothing happens. My cron schedule expressions is

21 20 * * * bash a.sh

And this sh script includes

cd /home/ubuntu/currencies_datas_get && python3 AAVEUSDT.py &
cd /home/ubuntu/currencies_datas_get && python3 ADAUSDT.py &
cd /home/ubuntu/currencies_datas_get && python3 APEUSDT.py &
cd /home/ubuntu/currencies_datas_get && python3 ATOMUSDT.py &

It suppose to launch these scripts along and it really works if you try to type bash a.sh to the ubuntu console


Solution

  • Assuming a.sh is in $HOME, make your crontab

    21 20 * * * bash $HOME/a.sh

    Additionally, depending on where your python3 binary is located, you may need to specify its full path, i.e., /usr/bin/python3 in your script.