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 :)
-
Possible duplicate of Running crontab with pythonstovfl– stovfl2018年10月28日 11:24:12 +00:00Commented 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.John Zwinck– John Zwinck2018年10月28日 11:33:06 +00:00Commented 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.John Zwinck– John Zwinck2018年10月28日 11:33:53 +00:00Commented 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.stovfl– stovfl2018年10月28日 11:49:49 +00:00Commented 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.TGrif– TGrif2018年10月28日 11:55:32 +00:00Commented Oct 28, 2018 at 11:55
1 Answer 1
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.
3 Comments
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.