0

First tested something simple like this, which works:

* * * * * echo "something" > /Users/sam/Desktop/vscode/crontest.txt

Now trying

28 10 * * * /Users/user/Desktop/work/venv/bin/python /Users/user/Desktop/work/py_files/test.py

But nothing is happening.

The python script ingests some data from API, parses JSON and outputs to a local mysql db

engine_insert = sqlalchemy.create_engine('mysql+pymysql://root:[email protected]:3306/database')
df.to_sql('database', engine_insert, if_exists='append', index=False)

But other simpler crons I also had issue with too like opening a website via browser so may just be a syntax issue with crontab?

1 Answer 1

1

I faced the same issue and I spent literally days to see where is my problem. So, try two things:

1- Follow these steps/instructions: https://stackoverflow.com/a/22744360/2080489

2- If you still facing the issue, try to stop any security module you have that might affect the connection. In my case, I am using Ubuntu so I stoped AppAromr:

sudo systemctl stop apparmor 

or in case you want to disable it

sudo systemctl disable apparmor 

check the app status by doing:

sudo systemctl status apparmor 
  • You may need to reboot your machine after stopping the app.

Hope this would help you.

Sign up to request clarification or add additional context in comments.

2 Comments

It is not advisable to stop AppArmor (you can find out more here). you could however, do this apt-get install apparmor-utils and then use sudo aa-complain /sbin/cron which would put the application in complain mode. meaning it will only log issues. You can then return it to rule enforcement using sudo aa-enforce /sbin/cron. I would also suggest you look at creating profiles for AppArmor to specify what your application can access.
Got it! Thanks Faris.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.