Automatically run qacct on job completion - sungridengine

I'd like to add a line to many qsub script which will run qacct for the job that has just completed. I realise I can do this after the fact with
qacct -j jobid
but I'd like to have it done automatically. The issue I'm having is parsing the job I'd before it's submitted. Is it possible to wildcard the job ID in some way?

According to manual for qsub the job id is available from within a script via the JOB_ID variable:
JOB_ID A unique identifier assigned by the
sge_qmaster(8) when the job was submitted.
The job ID is a decimal integer in the range
1 to 99999.
http://gridscheduler.sourceforge.net/htmlman/htmlman1/qsub.html
So at the end of your script just add:
qacct -j $JOB_ID

Related

how to Update status of order in mysql after 30days using sequelize nodejs

I have problems is: Auto-update order status if that status doesn't have any update in 30 days.
For example, the current status is " processing" and during 30days later, no more update on this. So the MySQL auto-update order status to "on Hold
I found and guest it something related to Hook, but I don't know how to implement it
depends on how you run you app. I'll suggest using e.g. some cron to get such instances and update it's status.(e.g. https://www.npmjs.com/package/node-cron)
Set it for example to run once a day, query such instances depends on build in column updatedAt. Or just to add some other column which will be updated with current date, depends what rules you want to apply
you can use cronjob.as npm says Cron is a tool that allows you to execute something on a schedule.
for install cron - 'npm i cron'
the (*) shows in order given details.
Seconds: 0-59 Minutes: 0-59 Hours: 0-23 Day of Month: 1-31 Months:
0-11 (Jan-Dec) Day of Week: 0-6 (Sun-Sat)
how to initialize cronjob:
var CronJob = require('cron').CronJob;
var job = new CronJob(
'* * * */30 * *',
function() {
console.log('every 30 days it is auto updated!');
},
null,
true,
'America/Los_Angeles'
);
make sure other parameters pass according to your application
and also cron use different port then your application.
As suggested by Damian you need to use a kind of CRON job which runs everyday to check for expired orders(created more than 30 days ago without any update).
You can use Bull with PM2
Create a processor in Bull and a queue and use the CRON functionality of Bull to set this job to run everyday usually at 12:05 AM or any time you see suitable.
The job would fetch all orders which have status "processing" and were created more than 30 days ago and update them.
Use PM2 to run Bull

How to create a trigger that resets values to zero after 30 days?

I have a table 'users'. In that table there is a field balance whose datatype is ENUM('Yes','No'). Now I want to create a trigger that is fired when the balance is set to "Yes". Also I want to reset the value of Balance to NO after 30 days.
I am using PHP Codeigniter. And I have a reseller table who has its own users. So Each reseller has some users.
So when a reseller sets the balance of user to yes the trigger should
be fired and after 30 days should set user balance to NO
Also the balance of each user should be Reset uniquely. I mean one uses's balance is set to yes today and user-two balance is set to Yes tomorrow . So how will trigger know when to fire for that each specific user?
My solution is
Maintain a column like updatedon.
Write a stored procedure to set balance to NO when updatedon is 30 days and balance is YES(according to your critaria)
Run a Job daily to invoke the stored procedure(It will set only 30 days back updated records)
In order to track date you need to keep a column on which user updated_to_yes_date. When ever user update that enum column to "Yes" you should set current date to updated_to_yes_date.
Now lets code the controller for cron job.
class Cronjob extends CI_Controller {
function index() {
// Get Date before 30 days.
$today = new DateTime();
$dateBefore30days = $today->modify('-30 days');
$this->db->update('users',array('enumcolumn'=>'No'), array('enumcolumn'=>'Yes', 'updated_to_yes_date'=>date_format($dateBefore30days , 'Y-m-d'));
}
}
I have not tested above controller but it will help you.
Now its time to set up cron job. You need to run this cron job every day. To know how to setup cron job on cPanel CLICK HERE
Now we need to execute controller method from command line. For that go to codeignitor Running via the CLI document.
In our case it will be like
$ php index.php cronjob index
In many case we need to provide full path to index.php like
$ php /path/to/webroot/index.php cronjob index

Notification that a JOB did not start in SQL Server Agent 2008

We are able to send notification regarding failure/success of a job but if a job does not start on its scheduled time can we create a script which will send a notification to my mail box saying that the "JOB did not start'?
Per documentation, below are the only cases which can be notified. So, JOB Doesn't start isn't even in the list; which means that you can't set a notification for that.
But my thinking is that, If you know that in a day you are supposed to get N email notification for N jobs, you can check that and find out which job didn't run.
When the job succeeds to notify the operator when the job completes successfully.
When the job fails to notify the operator when the job completes unsuccessfully.
When the job completes to notify the operator regardless of completion status.
SELECT DISTINCT
J.NAME AS 'JOBNAME',
MSDB.DBO.AGENT_DATETIME(RUN_DATE, RUN_TIME) AS 'RUNDATETIME'
INTO #TEMP
FROM MSDB.DBO.SYSJOBS J
INNER JOIN MSDB.DBO.SYSJOBHISTORY H
ON J.JOB_ID = H.JOB_ID
WHERE J.ENABLED = 1 --ONLY ENABLED JOBS
ORDER BY JOBNAME, RUNDATETIME DESC
IF NOT EXISTS (
SELECT * FROM #TEMP
WHERE JOBNNAME = 'JOBNAME'
AND RUNDATETIME = 'RUNDATETIME')
BEGIN
SEND AN EMAIL
END
There's no simple way to do this, but you can query the job history tables to check if the job start time has been logged. If it hasn't you can use an IF expression to send you an email.
Thanks.

how to get merged changes in json from gerrit code review

Is there a way i can get a json of all the changes in gerrit code review?
for example get all the merged changes from gerrit.aokp.co? It would be even better if i could get the changes from the previous day only.
You can use the query command on the ssh command line, adding the --format json option to get the data in JSON format.
To get merged changes use the status:merged query operator.
There is no query operator to get changes within a specific time range, but you can use the age operator to specify an amount of time passed since the change was last updated.
For example to get all changes merged within the last day:
$ ssh -p 29418 user#review gerrit query --format json status:merged age:1day
Note that by default this will return a limit of 500 results. To see more, you need to either increase the limit (if you're an administrator) or use multiple queries making use of the --resume_sortkey option.
See the documentation for more details:
Query command
Search operators

SSIS Check Ready Flag

I need help with an SSIS package. I have a server that populates a DB table as a part of a daily job. Then the server writes to a process status table to let me know that its done.
The process status table looks like this:
Job | Ready | Downloaded
myJob True False
I want to create a process that will check if the Ready Flag on myJob is True and proceed or if False it will sleep for 30 mintues before trying again and repeating up to 5 times.
I found this article on how to do the sleeping part:
http://blogs.conchango.com/jamiethomson/archive/2006/10/23/SSIS_3A00_-Put-a-package-to-sleep.aspx
I was thinking of using a file system task to access the process status table. Then set a variable to the value of the Ready flag. Then have a For loop Container, if true break out of the for loop and continue and if false run the sleep then run another file system task and set the variable to the value of the Ready flag. The main question I have is how do I set a variable to the value of the ready flag?
If you have a For Loop container, you can place an "ExecuteSql" task to extract your status value (i.e. false), then use a "ScriptTask" to store it or manipulate it as necessary. You can then continue to process the contents of your for loop container (this may be a dataflow task or what ever your using).
I was able to figure it out.
I used a Data Flow Task with a OLE DB Source and Script Component inside.
The Script Component read and handles the database data, does some basic if else logic, and writes to a system variable.
Writing to a variable from a Script Component tutorial:
"http://blogs.conchango.com/jamiethomson/archive/2006/07/18/SSIS_3A00_-But-it-used-to-work-in-DTS-_2800_7_2900_-2D00-Capture-a-value-from-inside-the-data-pump-into-a-variable.aspx"
I later use that system variable in a for loop.