I'm newbie play with Linux so I do apologize for maybe a silly question. The thing is that I'm trying to carry out a job execution automatically at 20 minutes every hour.

1) I create an sh file in my scripts folder:

.#!/bin/sh cd /home/ubuntu/scripts/dm-customer && python3 ./md_executor.py

1.1 I transform the sh file as executable :

  • chmod 755 etl-execution.sh
  • chmod +x etl-execution.sh

2) Now I typed crontab -e and add a line:

  • 55 * * * * ubuntu /home/ubuntu/scripts/dm-customer/etl-execution.sh

Then my cron should be triggered automatically but rather nothing is going on. I tried to:

  • Edit my crontab -e using ubuntu user rather than root but nothing happens
  • If I execute manually the sh in my ubuntu session it goes thru I really don't understand.

I appreciate any feedback this is driving me crazy. Thanks

  • 1
    I don't understand why you need a .sh script, you can directly call the python script from cron 20 * * * * python3 /home/ubuntu/scripts/dm-customer/md_executor.py – Félicien Apr 20 '18 at 15:09
  • The script is not executed because you use relative paths (e.g. ./md_executor.py). cron is executed form a different directory where md_executor.py is not in the current directory. If you typed in the whole pathname in your crontab, you should do it so also in the shell script or do as others suggest run md_executor.py directly from crontab. But be careful and put in whole pathnames as you do not know PATH settings for cron. I would also recommend to put pathname for python. If you do not know where python3 executable is type which python3 to see. – nobody Apr 20 '18 at 15:33
  • @nobody before he fires of the relative path command, he changes directory to the directory where the python script is. That should work. – vidarlo Apr 20 '18 at 17:58
55 * * * * ubuntu /home/ubuntu/scripts/dm-customer/etl-execution.sh

Why do you have Ubuntu there?

The format is, from man 5 crontab:

   The format of a cron command is similar to the V7 standard, with a num-
   ber  of upward-compatible extensions.  Each line has five time-and-date
   fields followed by a username (if this is the system crontab file), and
   followed  by  a  command.   Commands  are  executed by cron(8) when the
   'minute', 'hour', and 'month of the  year'  fields  match  the  current
   time, and at least one of the two 'day' fields ('day of month', or 'day
   of week') match the current time (see "Note" below).

Username shall only be included if it's the system crontab. If you're running crontab -e as your own user, it should not be included.


55 * * * * /home/ubuntu/scripts/dm-customer/etl-execution.sh

and see if that works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.