Download presentation
Presentation is loading. Please wait.
Published byAvis Poole Modified over 6 years ago
1
How to make job list activate an Aleph service twice a month or once a month
Yoel Kortick
2
Introduction The Aleph job_list from $alephe_tab is designed to work on a weekly basis. It is possible to have the job_list activate a secondary script which will then run the job on either a “every other week” or “once a month“ basis. There are many ways to do this, and here we will show only one way for each frequency.
3
Run the job and get parameters
The first step is to run the desired Aleph service once from GUI and then get desired parameters from $alephe_scratch log file Here we run ret-03
4
Run the job and get parameters
Here we get the parameters of the job ret-03 il-aleph02-19(4) USM50-YOELK>>cd $alephe_scratch il-aleph02-19(4) USM50-YOELK>>grep ^start usm01_p_ret_ start USM01,wti_library,wti=library, Here we make a simple script which includes a line to run the job (we will soon edit this script) il-aleph02-19(4) USM50-YOELK>>cat /exlibris/users/yoelk/aleph_op_p_ret_03_main csh -f $aleph_proc/p_ret_03 USM01,wti_library,wti=library, > $alephe_scratch/p_ret_03.log.`date '+%Y%m%d.%H%M%S'`
5
Twice a month - Make variable
Now we will make a second script which will contain a variable which will start as “Y” but, as we will see, change back and forth between Y and N every time the job is run. Here is the starting situation of the script. il-aleph02-19(4) USM30-YOELK>>cat /exlibris/users/yoelk/aleph_op_p_ret_03_variable set ran_previous_time = Y If source is done on this file then a parameter will be created “ran_previous_time”
6
Run the job depending on variable
Now we will edit the first script as follows: If the variable “ran_previous_time” = Y then the job will not run, and will change the file “aleph_op_p_ret_03_variable” so that next time “aleph_op_p_ret_03_main” is run the variable will be “N” If the variable “ran_previous_time” = N then the job will run, and will change the file “aleph_op_p_ret_03_variable” so that next time “aleph_op_p_ret_03_main” is run the variable will be “Y”
7
Run the job depending on variable
il-aleph02-19(4) USM30-YOELK>>cat /exlibris/users/yoelk/aleph_op_p_ret_03_main source /exlibris/users/yoelk/aleph_op_p_ret_03_variable if ($ran_previous_time == "Y") then echo "ran_previous_time" is $ran_previous_time echo "job not running because it ran last time" perl -pi -e 's/Y/N/' /exlibris/users/yoelk/aleph_op_p_ret_03_variable endif if ($ran_previous_time == "N") then echo "job running because it did not run last time" csh -f $aleph_proc/p_ret_03 USM01,wti_library,wti=library, > $alephe_scratch/p_ret_03.log.`date '+%Y%m%d.%H%M%S'` perl -pi -e 's/N/Y/' /exlibris/users/yoelk/aleph_op_p_ret_03_variable
8
Testing the script Now if we run the script then the first time it should not run p_ret_03 and the second time it should run p_ret_03 the third time it should not run p_ret_03 and the fourth time it should run p_ret_03 This will continue indefinitely
9
Testing the script Did not run Did run Did not run Did run
il-aleph02-19(4) USM30-YOELK>>csh -f /exlibris/users/yoelk/aleph_op_p_ret_03_main ran_previous_time is Y job not running because it ran last time il-aleph02-19(4) USM30-YOELK>> ran_previous_time is N job running because it did not run last time Did not run Did run Did not run Did run
10
Adding the script to job_list
Now all that is left to do is add the script to $alephe_tab/job_list for once a week. One week the script will run the ret_03 and the next week it will not. ! !!-!!!!!!!!-!-!!!!!!!!!!!!!!!!!!!!-!!!!!-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-!!!!!! 00 06:00:00 N ret_03.log csh -f /exlibris/users/yoelk/aleph_op_p_ret_03_main
11
Script for once a month Now we will make a script which will run p_ret_03 once a month, on a particular date every month The script will first check the date of the month and If it is a particular predefined date then ret_03 will run. If it is not a particular predefined date then ret_03 will not run.
12
Script for once a month There are many date options in UNIX
The command man date will show them all We will use date '+%d' which shows the numeric date of the month il-aleph02-19(4) USM30-YOELK>>date '+%d' 13
13
Script for once a month Here is the script as set to run only if the date is the 04th of the month: il-aleph02-19(4) USM30-YOELK>>cat /exlibris/users/yoelk/aleph_op_p_ret_03_once_a_month set day_of_month = "`date '+%d'`" if ($day_of_month == "04") then echo "Today's date is" $day_of_month echo "p_ret_03 will run" csh -f $aleph_proc/p_ret_03 USM01,wti_library,wti=library, > $alephe_scratch/p_ret_03.log.`date '+%Y%m%d.%H%M%S'` else echo "Today is not the 04th of the month, p_ret_03 will not run" endif When date is 04 script will run When date is not 04 script will not run
14
Script for once a month Here is what happens when the date is not the 04th of the month: il-aleph02-19(4) USM30-YOELK>>csh -f /exlibris/users/yoelk/aleph_op_p_ret_03_once_a_month Today's date is 13 Today is not the 04th of the month, p_ret_03 will not run Here is what happens when the date is the 04th of the month: il-aleph02-19(4) USM30-YOELK>>csh -f /exlibris/users/yoelk/aleph_op_p_ret_03_once_a_month Today's date is 04 p_ret_03 will run il-aleph02-19(4) USM30-YOELK>> il-aleph02-19(4) USM30-YOELK>>cd $alephe_scratch il-aleph02-19(4) USM30-YOELK>>ls -lrt | tail -1 -rw-rw-r aleph exlibris Jan 04 13:02 p_ret_03.log
15
Script for once a month Now all we have to do is add this to job list to run every day. When it is the fourth of the month is will activate ret_03, and when it is not the fourth of the month it will not activate ret_03. ! !!-!!!!!!!!-!-!!!!!!!!!!!!!!!!!!!!-!!!!!-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-!!!!!! W3 06:00:00 N ret_03_month.log csh -f /exlibris/users/yoelk/aleph_op_p_ret_03_once_a_month
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.