Jobber is a tool written with a mindset of creating a simpler mechanism for scheduling jobs. It's written is GO so you need to install it in order to use jobber. you can download jobber as an rpm here.
Jobber does not daemonize on its own so we also need to install daemonize package which is available in EPEL repository.
Creating jobs:
Every individual user has their own set of jobs which will run with their privileges on the system. A users' jobs are defined in a jobfile named .jobber in the users' home directory. The jobs are defined in YAML format & it took me forever to get the syntax right.
Here is a test job I wrote:
[test@centops ~]$ cat .jobber
---
- name: test_job
cmd: |
uname
uptime
time: 0 0 13
onError: Stop
notifyOnError: true
notifyOnFailure: false
[test@centops ~]$
The fields of a job definition are:
Jobber does not daemonize on its own so we also need to install daemonize package which is available in EPEL repository.
Creating jobs:
Every individual user has their own set of jobs which will run with their privileges on the system. A users' jobs are defined in a jobfile named .jobber in the users' home directory. The jobs are defined in YAML format & it took me forever to get the syntax right.
Here is a test job I wrote:
[test@centops ~]$ cat .jobber
---
- name: test_job
cmd: |
uname
uptime
time: 0 0 13
onError: Stop
notifyOnError: true
notifyOnFailure: false
[test@centops ~]$
The fields of a job definition are:
Time strings:
In order from left to right, these are the time components corresponding to the specifiers:
In order from left to right, these are the time components corresponding to the specifiers:
- second
- minute
- hour
- day of month
- month
- day of week
Every time you update the .jobber job file, you need to reload jobber as follows:
[test@centops ~]$ jobber reload
Loaded 1 jobs.
To list loaded jobs type:
[test@centops ~]$ jobber list
NAME STATUS SEC/MIN/HR/MDAY/MTH/WDAY NEXT RUN TIME NOTIFY ON ERR NOTIFY ON FAIL ERR HANDLER
test_job Good 0 0 13 * * * Sep 15 13:00:00 2016 true false Stop
To check whether the job is syntactically correct, we can test the job with 'jobber test':
[test@centops ~]$ jobber test test_job
Running job "test_job" for user "test"...
Job "test_job" succeeded.
New status: Good.
Stdout:
Linux
11:10:54 up 1:27, 5 users, load average: 0.05, 0.16, 0.13
Stderr:
Here is an example of a .jobber file consisting of more than one jobs:
[test@centops ~]$ cat .jobber
---
- name: test_job
cmd: |
uname
uptime
time: 0 0 13
onError: Stop
notifyOnError: true
notifyOnFailure: false
- name: testjob
cmd: df
time: 0 1 17
onError: Stop
notifyOnError: true
notifyOnFailure: false
[test@centops ~]$ jobber reload
Loaded 2 jobs.
[test@centops ~]$ jobber list
NAME STATUS SEC/MIN/HR/MDAY/MTH/WDAY NEXT RUN TIME NOTIFY ON ERR NOTIFY ON FAIL ERR HANDLER
test_job Good 0 0 13 * * * Sep 15 13:00:00 2016 true false Stop
testjob Good 0 1 17 * * * Sep 15 17:01:00 2016 true false Stop
[test@centops ~]$
No comments:
Post a Comment