-1

I'm trying to use Python-crontab module over Linux OS (CentOS 7)

My config file is as follows:

{
 "ossConfigurationData": { 
 "work1": [
 { 
 "cronInterval": "0 0 0 1 1 ?", 
 "attribute": [
 { 
 "rules": [
 {
 ......
 }
 ] 
 }
 ],
 "work2": [
 { 
 "cronInterval": "0 0 0 1 2 ?", 
 "attribute": [
 { 
 "rules": [
 {
 ......
 }
 ] 
 },
 ]
 }

}

The file contain many work items. Each work item has it own cron expression. I want my Python script to be able to schedule each cron separately, set it in my OS & run it. When running, the purpose is running each work item separately according to it cron expression I did step-by-step according to this tutorial. After many tests it's writing the cron, but I'm not sure it's what I need

Using this module, I can't create reference to the relevant work item. It's just adding a new line to the OS crontab with any execution I want to put there. I can't describe what I wish to run (i.e. - work1 or work2)

Any suggestions?

10x in advance :)

asked Oct 28, 2018 at 9:37
6
  • Possible duplicate of Running crontab with python Commented Oct 28, 2018 at 11:24
  • @stovfl: That link you said is a duplicate is about running Python programs on a schedule configured in cron. This question is about configuring cron using a Python program. Commented Oct 28, 2018 at 11:33
  • "Nothing works" is never an adequate problem description. Show us the code you tried and tell us exactly what happened when you ran it. Commented Oct 28, 2018 at 11:33
  • "but nothing works": Whera are the differents between running a Python Script or any executable, the Cron setup is the same. Edit your Question and explain your nothing works. Commented Oct 28, 2018 at 11:49
  • According to the GitLab repo and the pypi sumary, this module is still supported. And of course not, it is not limited to Ubuntu distro. Commented Oct 28, 2018 at 11:55

1 Answer 1

0

A common error is not using the cron.save() function after editing. Given the limited information in the question, this is the most likely answer.

answered Oct 28, 2018 at 20:03
Sign up to request clarification or add additional context in comments.

3 Comments

Hi @Martin - I'm not using cron.save(). I'll try to be more clear - I have Json config file that contain many work items. Each work item has it own cron expression. I want my Python script to be able to schedule each cron separately, set it in my OS & run it, when the cron occur, with the content of the specific work item.
Hi Aviv, What you're describing isn't a problem in the python-crontab module, but some connection between the json and your crontab. I don't understand enough about your codebase to know why it's not working. It should and what you're asking for is reasonable. Alsa something isn't right.
Hi @Martin. I've updated my original question with code sample. Pls. take a look

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.