SanPySchedule 2.0.0
SanPySchedule - A Job Scheduler For Docker Environment
License: MIT

# SanPySchedule - A Job Scheduler For Docker Environment

## Dependencies

```bash
1. Install python3 into your local computer
    Please follow Python install instructions mentioned in
    https://www.python.org/downloads/

NOTE: No separate package or framework required for running SanPySchedule

```

## Installation

```bash

pip install SanPySchedule

```

## Source Code

```bash

Clone the git repository to your local computer.
git clone https://github.ibm.com/santanu-lab/SanPySchedule.git

```

## Description And Features

```bash

SanPySchedule Python Library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The library provides a easy solution to job scheduling problem due to unavailability of standard job Scheduler like in docker and Kubernetes  environment.

1. A simple to use API for scheduling jobs.
2. Unlike crontab file, the scheduling information can be stored in a JSON file
   which can be input to Library.
3. Very lightweight and no external dependency required.

```

## Usage

```bash

Step :1: Create a JSON File
~~~~~~~~~~~~~~~~~~~~~~~~~~~

a) JSON file name can be anything, but you must follow the following key value pair names in JSON.

b) Change the value for pyJobName key to the required job name you want scheduler to execute.

c) You must not change the format of  pyJobSchedule key value.
   It should be in the format "every-xxxx-yyyy"
   where xxxx should be second, day, minute and
         yyyy should be time value

d) Incase of weekly job the format should be every-week-aaaa-bbbb
   where aaaa is the day name like monday, tuesday etc. And
         bbbb is time value when the scheduler will execute the job.
{
    "pyJobDetails":[
        {
            "pyJobName":"ls -lrt",
            "pyJobSchedule":"every-seconds-5"
        },
        {
            "pyJobName": "cat test.txt",
            "pyJobSchedule": "every-day-20:43"
        },
        {
            "pyJobName": "date",
            "pyJobSchedule": "every-minute-30"
        },
        {
            "pyJobName": "df -k .",
            "pyJobSchedule": "every-week-monday-18:57"
        }
    ]
}

Step :2: Create your main function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    i)  Import Library to your code and pass the JSON file name to SanPySchedule
        class, and your JOB scheduler is ready.

        from SanPySchedule import SanPySchedule

    ii) in the main function create the scheduler object.

        from SanPySchedule import SanPySchedule
        def main():
            sps = SanPySchedule('SanJobTab.json')
            sps.scheduleAllJobs()

        if __name__ == "__main__":
            main()

Step :3: Sample Code
~~~~~~~~~~~~~~~~~~~~~
Please refer Example directory for detailed code.

```

## Known Issues

```bash

Exception handling module need more refinement. I will provide the list ASAP.

```

## License

```bash

MIT License

Copyright (c) 2020 Santanu Mohapatro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

```

## Author

```bash

Santanu Mohapatro
(mksantanu@me.com)
IBMers can contact me via.
Mail: shmohapa@in.ibm.com
SLACK: @mksantanu

```