I am working on shell script which will clean all the older logs and I would like to schedule this job autosys but since I have multiple servers where this job should run hence looking for the information that how to create a single JIL file to run the job on multiple boxes ?
Sample JIL:
insert_job: cleanup job_type: cmd
description: "This job will cleanup logs from server"
machine: <server_name>
owner: <user_name>
max_run_alarm: 0
alarm_if_fail: y
alarm_if_terminated: y
date_conditions: y
send_notification: n
days_of_week: we,sa
start_times: "00:00"
command: /test/autosys/cleanup.sh
std_out_file: >> /test/autosys/cleanup_`hostname`_`date+%Y%m%d`.out
std_err_file: >> /test/autosys/cleanup_`hostname`_`date+%Y%m%d`.err
In another question I read that we can't give multiple server name in machine tag by comma separated because job will run on either of the server. But I want job to be run to all the servers. How to achieve that ?
Achieving by a single job seems not in the scope of Autosys.
However, the most efficient way to achieve this would be implementing box job.
Step01: Create individual jobs for each host, Cleanup_on_HostA and Cleanup_on_HostB so on
Step02: Group the individual job into a box and schedule the box. This way all the jobs inside the box would start parallelly.
Sample JIL:
insert_job: Housekeeping_Box
job_type: box
date_conditions: y
days_of_week: we,sa
start_times: "00:00"
insert_job: Cleanup_on_HostA
job_type: cmd
box_name: Housekeeping_Box
description: "This job will cleanup logs from server"
machine: <hostA>
owner: <user_name>
max_run_alarm: 0
alarm_if_fail: y
alarm_if_terminated: y
command: /test/autosys/cleanup.sh
std_out_file: >> /test/autosys/cleanup_`hostname`_`date+%Y%m%d`.out
std_err_file: >> /test/autosys/cleanup_`hostname`_`date+%Y%m%d`.err
insert_job: Cleanup_on_HostB
job_type: cmd
box_name: Housekeeping_Box
description: "This job will cleanup logs from server"
machine: <hostB>
owner: <user_name>
max_run_alarm: 0
alarm_if_fail: y
alarm_if_terminated: y
command: /test/autosys/cleanup.sh
std_out_file: >> /test/autosys/cleanup_`hostname`_`date+%Y%m%d`.out
std_err_file: >> /test/autosys/cleanup_`hostname`_`date+%Y%m%d`.err
Related
We are new in the salt stack. Our use case is to Schedule a run python/go script on salt-master. Is there any way or configuration to do the same?
Yes, you can schedule anything: Job Management
To run a script from the master process (not a minion):
schedule:
job1:
function: salt.cmd
args:
- cmd.run
- /path/to/script
when: whenever
That uses the salt.cmd runner to run the cmd.run function on the master, running the given script.
If you have a minion on the master server, you can use that instead and save a level of indirection.
I am trying to set up repmgr version 5 on Debian with PostgtrSql 11.
Seems like the documentation is more oriented towards centos/RHEL.
When I am trying to setup the witnes node to start the repmgr daemon, I get an error without any idea where to look for for seeing what is the cause of the error.
This is my repmgr.conf file:
node_id=3
node_name='PG-Node-Witness'
conninfo='host=10.97.7.140 user=repmgr dbname=repmgr connect_timeout=2'
data_directory='/var/lib/postgresql/11/main'
failover='automatic'
promote_command='/usr/bin/repmgr standby promote -f /etc/repmgr.conf --log-to-file'
follow_command='/usr/bin/repmgr standby follow -f /etc/repmgr.conf --log-to-file --upstream-node-id=%n'
priority=60
monitor_interval_secs=2
connection_check_type='ping'
reconnect_attempts=6
reconnect_interval=8
primary_visibility_consensus=true
standby_disconnect_on_failover=true
repmgrd_service_start_command='sudo /etc/init.d/repmgrd start' #??????
repmgrd_service_stop_command='sudo //etc/init.d/repmgrd stop'#??????
service_start_command='sudo /usr/bin/systemctl start postgresql#11-main.service'
service_stop_command='sudo /usr/bin/systemctl stop postgresql#11-main.service'
service_restart_command='sudo /usr/bin/systemctl restart postgresql#11-main.service'
service_reload_command='sudo /usr/bin/systemctl relaod postgresql#11-main.service'
monitoring_history=yes
log_status_interval=60
register is OK:
repmgr -f /etc/repmgr.conf witness register -h 10.97.7.97
INFO: connecting to witness node "PG-Node-Witness" (ID: 3)
INFO: connecting to primary node
NOTICE: attempting to install extension "repmgr"
NOTICE: "repmgr" extension successfully installed
INFO: witness registration complete
NOTICE: witness node "PG-Node-Witness" (ID: 3) successfully registered
repmgr daemon dry-run OK too:
$repmgr -f /etc/repmgr.conf daemon start --dry-run
INFO: prerequisites for starting repmgrd met
DETAIL: following command would be executed:
sudo /usr/bin/systemctl start postg...#11-main.service
I setup /etc/default/repmgrd with:
REPMGRD_ENABLED=yes
and
REPMGRD_CONF="/etc/repmgr.conf"
But still get error when trying to run the daemon start:
$ repmgr -f /etc/repmgr.conf daemon start
I get:
NOTICE: executing: "sudo /etc/init.d/repmgrd start"
ERROR: repmgrd does not appear to have started after 15 seconds
HINT: use "repmgr service status" to confirm that repmgrd was successfully started
It is recommended to run repmgrd as a systemd service,
According to the docs (for debian) you may first need to configure /etc/default/repmgrd,
My configuration looks like this:
# default settings for repmgrd. This file is source by /bin/sh from
# /etc/init.d/repmgrd
# disable repmgrd by default so it won't get started upon installation
# valid values: yes/no
REPMGRD_ENABLED=yes
# configuration file (required)
REPMGRD_CONF="/etc/repmgr/12/repmgr.conf"
# additional options
REPMGRD_OPTS="--daemonize=false"
# user to run repmgrd as
REPMGRD_USER=postgres
# repmgrd binary
REPMGRD_BIN=/bin/repmgrd
# pid file
REPMGRD_PIDFILE=/var/run/repmgrd.pid
Secondly, I would revisit sudoers (visudo) in order to check whether the non-root user can execute sudo /etc/init.d/repmgrd start.
Further, the user who runs repmgr commands should be able to write logs depending on your configuration.
Apparently the correct command to start the repmgr daemon is:
repmgrd -f /etc/prepmgr.conf
for my tests I need a dummy server which outputs sample/test code. I use a node http server for that and start it before my scripts with node ./test/server.js.
I can start it, but the issue is that it's taking up the instance and therefore can't run the tests now.
So the question is, how can I run the server in the background/new instance so it doesn't conflict with that? I do stop the server with the end_script so I don't have to terminate it.
This is my travis-config so far:
language: node_js
node_js:
- "6.1"
cache:
directories:
— node_modules
install:
- npm install
before_script:
- sh -e node ./test/server.js
script:
- ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/jelly.html
- ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/form.html
- ./node_modules/mocha/bin/mocha ./test/node/jelly.js
after_script:
- curl http://localhost:5555/close
You can background the process by appending a &:
before_script:
- node ./test/server.js &
Scenario : Two jobs are in a BOX_JOB - JOB_1 and JOB_2 , JOB_2 is dependent on JOB_1 Success and should fail whenever JOB_1 fails.
Observation: Once the BOX_JOB gets activated JOB_1 and JOB_2 both gets activated , but JOB_2 continues to be activated even when JOB_1 has completed as failure
JOB_2 JIL
job_type: cmd
....
condition: s(JOB_1)
box_name: BOX_JOB
Check out the box_terminator attribute. Set box_terminator: 1 (or y) in the JIL for JOB_1 and it will terminate BOX_JOB if JOB_1 fails and JOB_2 should go to INACTIVE.
Check out page 204 (among others) of the Autosys Reference Guide (pdf) for more.
How can I set a job in autosys which will run evening from 4pm to 5pm every 10 minutes?
Please help me how I can specify then start time parameter. I am new to this JIL script.
Also where can I get the complete details about scheduling a job using JIL script?
You can give the attribute start_mins for every 10 mins with the run_window. You can schedule jobs for every minute but you do not have it in seconds.
date_conditions: 1
days_of_week: all
start_mins: 00,10,20,30,40,50
run_window: "16:00-17:00"
timezone: india
/* ----------------- template ----------------- */
insert_job: template job_type: c
box_name: box1
command: <xxx>
machine: <hostname>
owner: <username>
permission: gx,ge
date_conditions: 1
days_of_week: all
start_mins: 0,30
run_window: "16:00-17:00
please refer to the cheatsheet for further details
http://supportconnectw.ca.com/public/autosys/infodocs/autosys_cheatsheet.asp
Use start_mins: "00,10,20,30,40,50"