I'm newbie making cronjobs with linux. My goal is to execute a python script in its own virtual enviroment.

To do this I have made first a shell script called twitter.sh where its content is:

source /home/josecarlos/Workspace/python/robot2-rss/venv/bin/activate 
python /home/josecarlos/Workspace/python/robot2-rss/main.py R,1

And its route is:


We have access to source and python commands due their routes /usr/bin are included in the PATH variable as you can see in the next image:


The config of my cronjob is:

# m h  dom mon dow   command
*/1 * * * * /home/josecarlos/Workspace/python/robot2-rss/twitter.sh

However, this configuration of my cron job doesn't works and I don't know what am I doing wrong :(

Edit I:

I have modified my twitter.sh script to this new code:


/home/josecarlos/Workspace/python/robot2-rss/venv/bin/python /home/josecarlos/Workspace/python/robot2-rss/main.py R,1

If I run the script directly works fine but with the cron job doesn't work!!! :(

Edit II:

How in the last modification from twitter.sh I just only was calling to my python script, I have modified my cron job to call directly to the python script like this:

# m h  dom mon dow   command
* * * * * /home/josecarlos/Workspace/python/robot2-rss/venv/bin/python /home/josecarlos/Workspace/python/robot2-rss/main.py R,1

And it doesn't work :( I don't know what happen :(

  • Could you replace the images with text? Not everybody, and not every software tool, can read pictures. Commented Jul 7, 2021 at 0:34

1 Answer 1


set a proper shell

edit twitter.sh

source /home/josecarlos/Workspace/python/robot2-rss/venv/bin/activate 
python /home/josecarlos/Workspace/python/robot2-rss/main.py R,1

be sure to set PATH.

log result of command

in crontab add login part

*/1 * * * * /home/josecarlos/Workspace/python/robot2-rss/twitter.sh >> /var/log/twitter.log 2>&1

if something goes wrong, you can have a look at /var/log/twitter.log

  • Thanks @Archemar!!! Your solution has help me a lot!!! Commented Jul 7, 2021 at 10:49
  • 1
    where should we set PATH to?
    – Fayaz
    Commented Mar 28, 2023 at 10:04
  • @Fayaz this depend completly on your context
    – Archemar
    Commented Mar 28, 2023 at 13:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .