Running Cron Job on Amazon Instance with Bitnami

I have a python file programmed that makes an automatic backup of my Amazon instance.

In this instance I have Mautic Bitnami installed.

I have tried to run the file from the next line, directly in the terminal and it works correctly.

python3 /home/bitnami/aws/snapshot_script.py --volume-ids = vol-07701xxxxxxxxxx --expiry-days = 7

(Create a backup that expires in 7 days.)

This is how the snapshot_script.py file begins:

#!/usr/bin/env python3

The problem starts when I want to execute the line of code in a cron job, it does not work.

I have tried many things without getting results, for example:

  • Change python to /usr/bin/python3
  • Change python to //usr/bin/env python3
  • Use your bitnami -s when starting the cron
  • sudo crontab -l to see if it is executed (yes it does)
  • sudo adduser bitnami daemon recommended on the web
  • Copy the structure of the other crons:

    /5 * * * * su daemon -s /bin/sh -c "/opt/bitnami/php/bin/php -q /opt/bitnami/apps/mautic/htdocs/app/console mautic:segments:update" #mautic-segments-cron

the results of locate python are:

/usr/bin/python3.5 
/usr/bin/python3.5m 
/usr/lib/python2.7 
/usr/lib/python3.5 
/etc/python3.5 
/usr/local/lib/python3.5 
/usr/include/python3.5m 
/usr/share/

How should I proceed?

3
Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article