Add time-lag in whenever with capistrano between same role? - capistrano

I want to add time-lag between same role. e.g. roles :app = [app1, app2, app3]
My expectation(pseudo code):
app1: "1 * * * * rake 'heavy:task'"
app2: "3 * * * * rake 'heavy:task'"
app3: "2 * * * * rake 'heavy:task'"
1,2,3 is not important, but time-lag is important.
How to add time-lag between same role?
My actual schedule.rb:
every :hour, roles: [:app] do
rake 'heavy:task'
end
Actual result(pseudo code):
app1: "0 * * * * rake 'heavy:task'"
app2: "0 * * * * rake 'heavy:task'"
app3: "0 * * * * rake 'heavy:task'"

My stab at this. Sleep randomly for 6 seconds, executed serverside
every :hour, roles: [:app] do
on :all, in: :parallel do
execute 'sleep #{rand(6)}'
rake 'heavy:task'
end
end

Related

Issue with aix sed command

I am trying to uncomment "/usr/lib/sa/sa1" or "/usr/lib/sa/sa2" entries from one of the configuration file.
Below is the regex:
"^[0-9].*/usr/lib/sa/sa(1|2)"
Eg:
#0 * * * * /usr/lib/sa/sa1 1200 3 &
#5 23 * * * /usr/lib/sa/sa2 -s 0:00 -e 23:01 -i 3600 -ubcwyaqvm &
Output should be:
0 * * * * /usr/lib/sa/sa1 1200 3 &
5 23 * * * /usr/lib/sa/sa2 -s 0:00 -e 23:01 -i 3600 -ubcwyaqvm &
Tried the below "sed" command but no luck:
sed -e '/^#.*\/usr\/lib\/sa\/sa\(1\|2\)/s/^#//g' adm
Can you please let me know where am I going wrong here.
Thanks in advance!
You can use
sed '/^#.*\/usr\/lib\/sa\/sa[12]/s/^#//'
Here, no grouping construct is used, no alternation operator is used either. It is possible as the 1 and 2 are single char alternatives, and bracket expressions are supported in all versions of sed.
Also, see this online demo.

replacing first pattern using sed

I have a cron job with below details
The timing section is unknown, it might be hourly or daily.
cat zyx.txt
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
0 * * * * root /usr/local/bin/log-cleaner
I have to update it on the fly using sed, so that it should run every minute .
Here is what I have tried
sed -in 's/\(.*\) \(.*\) \(.*\)/\* \* \* \* \*/1' zyx.txt
But it is removing the user and path section
cat zyx.txt
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * *
Any help / suggestion using sed is much appreciated

unable to use Crontab in Linux?

i use fallowing command to excute my script in every 30 min
*/30 * * * * /home/g-m-iqbal/Desktop/Auto/algo.sh
and also try this
*/30 * * * * /home/g-m-iqbal/Desktop/Auto/ && sh algo.sh
here
/home/g-m-iqbal/Desktop/Auto this the path of script

Cron expression difference between */5 and 0/5

I have a cron properties file and some of the properties contain expression like:
"* 0/5 * * * ?"
and some of them contain:
"* */5 * * * ?"
What is the difference between the two?
If I want to run every 5 minutes then which one should be used?
Thanks
PS: My project is using spring scheduler.
You can use "*/5 * * * * *" for every 5 minutes and 0 0/5 8-10 * * * for every 5 minutes between 8 o'clock and 10 o'clock
For more info read this

How to define a macro variable using equation with variables from dataset in SAS Miner

I am trying to use &let in the beginning of my script to define a new macro variable... it should consist of equation from variables from dataset. The equation looks something like this, but SAS always gives me error like this (Runtime error was encountered, please see the log...).
The equation:
%let var_bad = (receivable_actual * 0.5) -
(EM_EVENTPROBABILITY * 0.02 * receivable_actual) +
((1 - EM_EVENTPROBABILITY) * 0.5 * (receivable_actual - amt_instalment));
Can you guys help me fix it?
Thanks,
Adam
#Jetzler: These are the errors it shows me in log.
ERROR 214-322: Variable name ( is not valid.
ERROR 22-7: Invalid option name -.
ERROR 23-7: Invalid value for the KEEP option.
---
23
1 ! (receivable_actual * 0.5) - (EM_EVENTPROBABILITY * 0.02 * receivable_actual) + ((1 - EM_EVENTPROBABILITY) * 0.5 * (receivable_actual - amt_instalment))
- -
214 22
ERROR 214-322: Variable name * is not valid.
ERROR 22-7: Invalid option name +.
1 ! (receivable_actual * 0.5) - (EM_EVENTPROBABILITY * 0.02 * receivable_actual) + ((1 - EM_EVENTPROBABILITY) * 0.5 * (receivable_actual - amt_instalment))
--- -
214 22
14338 + rename=(em_eventprobability = score_no_call));
-------
22 22
201 76
ERROR 214-322: Variable name 0.5 is not valid.
ERROR 22-7: Invalid option name *.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, END, INDSNAME, KEY, KEYS, NOBS, OPEN, POINT, DATA, LAST, NULL.
ERROR 201-322: The option is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
Why don't you just calculate the variable in the dataset and then select it into a macro variable?