Profiles / Programming
SD

Scheduler developer

Cron jobs and delayed runs: add, resume, pause, update and remove jobs, prove they ran, and postpone stack runs with a delay condition.

10 recipes on this page · open in the interactive view

Recipes
  1. A heartbeat job every 2 seconds: run, pause, resume, remove
  2. Generate the update request and change the cron
  3. Prove a job ran with the log table
  4. Postpone a stack run until a condition is true
  5. Check cron expressions before deploying jobs
  6. Run a job on one node of a cluster
  7. Audit your own jobs and generate their redeploy script
  8. A job that only queues work in the stack
  9. A frequent job that works only in business hours
  10. A sampling job and statistics on its rolling window
executed on MentDB

A heartbeat job every 2 seconds: run, pause, resume, remove

An integration must prove it is alive. The script adds an active heartbeat job every 2 seconds, scheduled at once, proves that it ran with a sequence counter, pauses it and checks that the counter stops, resumes it, then removes it.

Pipeline
Script
admin
#1. The job script and its counter;
script create exe "tuto.as.heartbeat" false 1
	(param
	;)
	"Heartbeat of the integration"
{
	sequence increment "tuto_as_beats";
} "The beat number";
sequence add "tuto_as_beats" 0;
#2. Add the job active: it is scheduled at once;
job add "tuto_as_heartbeat" "tuto.as.heartbeat.exe" "0/2 * * * * ?" true;
wait "9000";
-> "[b1]" (sequence get current "tuto_as_beats");
#3. Pause: the counter stops;
job pause "tuto_as_heartbeat";
json load "tuto_as_j" (job show);
-> "[state]" (concat (json select "tuto_as_j" "/tuto_as_heartbeat/pattern") " activate=" (json select "tuto_as_j" "/tuto_as_heartbeat/activate") " by " (json select "tuto_as_j" "/tuto_as_heartbeat/login"));
wait "5000";
-> "[b2]" (sequence get current "tuto_as_beats");
#4. Resume for a few beats, then remove;
job resume "tuto_as_heartbeat";
wait "5000";
job pause "tuto_as_heartbeat";
-> "[b3]" (sequence get current "tuto_as_beats");
job remove "tuto_as_heartbeat";
-> "[gone]" (job exist "tuto_as_heartbeat");
json unload "tuto_as_j";
sequence remove "tuto_as_beats";
script delete "tuto.as.heartbeat.exe";
concat "beats after 9 s: " [b1] [_n_] "paused: " [state] ", beats 5 s later: " [b2] [_n_] "resumed 5 s: " [b3] " beats" [_n_] "job exists after remove: " [gone]
Result
mentdb
beats after 9 s: 5
paused: 0/2 * * * * ? activate=0 by admin, beats 5 s later: 5
resumed 5 s: 8 beats
job exists after remove: 0
Go further
  • job add ... true schedules the job at once; job pause takes it out of the scheduler and job resume puts it back.
  • Write the beat time in a tuto_ node to alert when it gets too old.
executed on MentDB

Generate the update request and change the cron

A daily digest job exists at 06:00 and inactive. The developer generates its update request, rewrites the cron to every 3 seconds for a demo and activates it with `job update`, which applies at once, checks it in the list of active jobs and the counter, then removes it.

Pipeline
Script
admin
#1. A daily digest at 06:00, inactive;
script create exe "tuto.as.digest" false 1
	(param
	;)
	"Build the daily digest"
{
	sequence increment "tuto_as_digests";
} "1";
sequence add "tuto_as_digests" 0;
job add "tuto_as_digest" "tuto.as.digest.exe" "0 0 6 * * ?" false;
#2. The update request to edit;
-> "[gen]" (job generate update "tuto_as_digest");
#3. Every 3 seconds and active: the update applies at once;
job update "tuto_as_digest" "tuto.as.digest.exe" "0/3 * * * * ?" true;
wait "7000";
#4. Find it in the active jobs;
json load "tuto_as_act" (job show activate);
-> "[line]" "not active";
for (-> "[i]" 0) (< [i] (json count "tuto_as_act" "/")) (++ "[i]") {
	if (equal (json select "tuto_as_act" (concat "/[" [i] "]/[0]")) "tuto_as_digest") {
		-> "[line]" (concat (json select "tuto_as_act" (concat "/[" [i] "]/[1]")) " every " (json select "tuto_as_act" (concat "/[" [i] "]/[2]")));
	};
};
-> "[n]" (sequence get current "tuto_as_digests");
#5. Cleanup;
job pause "tuto_as_digest";
job remove "tuto_as_digest";
json unload "tuto_as_act";
sequence remove "tuto_as_digests";
script delete "tuto.as.digest.exe";
concat "generated:" [_n_] [gen] [_n_] "active: " [line] ", digests built in 7 s: " [n]
Result
mentdb
generated:
job update "tuto_as_digest" "tuto.as.digest.exe" "0 0 6 * * ?" false;
job pause "tuto_as_digest";
job resume "tuto_as_digest";
active: tuto.as.digest.exe every 0/3 * * * * ?, digests built in 7 s: 3
Go further
  • Paste the generated lines in a deploy script to recreate the same job on another server.
  • job update applies the new cron and the activation at once, even while the job runs: the pause and resume lines of the generated request are optional.
executed on MentDB

Prove a job ran with the log table

Operations want evidence that the purge job ran. The job script writes a log line with a client key; the developer searches the logs of that script and key, and reads how long such lines are kept.

Pipeline
Script
admin
#1. The purge job script logs what it did, its activity log is on;
script create exe "tuto.as.purge" true 1
	(param
	;)
	"Purge the temporary carts"
{
	-> "[n]" (sequence increment "tuto_as_purges");
	log write (concat "purge run " [n] ": 0 carts removed") "OK" "tuto_as_job" "purge";
	log trace (concat "tuto_as purge run " [n] " campaign " (node select "tuto_as_purge_cfg" /campaign));
} "1";
sequence add "tuto_as_purges" 0;
#2. A campaign id in a node, read by the job script, every 2 seconds for the demo;
-> "[camp]" (string generate_random_str 6);
node create "tuto_as_purge_cfg";
node iobject "tuto_as_purge_cfg" / "campaign" [camp] STR;
-> "[t0]" (date now);
job add "tuto_as_purge" "tuto.as.purge.exe" "0/2 * * * * ?" true;
wait "7000";
#A job cannot be paused while it runs: retry until it is between two runs;
-> "[paused]" 0;
while (== [paused] 0) {try {job pause "tuto_as_purge"; -> "[paused]" 1;} {wait "200";} "[err]";};
job remove "tuto_as_purge";
#3. The proof: log lines of this script and key since the start;
json load "tuto_as_l" (string substring (log search "ok" "tuto.as.purge.exe" "tuto_as_job" "purge" null [t0] (date dateaddt (date now) "MIN" 1) ASC 1 20) 39);
-> "[n]" (json count "tuto_as_l" "/data");
-> "[first]" (concat (json select "tuto_as_l" "/data/[0]/dtinsert") " " (json select "tuto_as_l" "/data/[0]/msg"));
-> "[last]" (concat (json select "tuto_as_l" (concat "/data/[" (- [n] 1) "]/dtinsert")) " " (json select "tuto_as_l" (concat "/data/[" (- [n] 1) "]/msg")));
#4. The same runs in the text log of the server, and how long the proof is kept;
-> "[traces]" (string regexp_count (log show 200) (concat "tuto_as purge run [0-9]+ campaign " [camp]));
-> "[keep]" (concat "kept " (log retention day) " days, then archived in " (log archive path) " by files of " (log archive size));
json unload "tuto_as_l";
sequence remove "tuto_as_purges";
script delete "tuto.as.purge.exe";
node delete "tuto_as_purge_cfg";
concat [n] " log lines found, " [traces] " lines of campaign " [camp] " in the text log" [_n_] "first: " [first] [_n_] "last:  " [last] [_n_] [keep]
Result
mentdb
4 log lines found, 4 lines of campaign TrHb4e in the text log
first: 2026-11-01 17:50:48 purge run 1: 0 carts removed
last:  2026-11-01 17:50:54 purge run 4: 0 carts removed
kept 50 days, then archived in archives/logs by files of 30
Go further
  • Filter on errors with the status ko: a failing job writes a JOB ERROR line for its script.
  • log trace writes to the text log of the server instead, read it with log show 20.
executed on MentDB

Postpone a stack run until a condition is true

A payment batch must not be settled before the bank file is there. The script sets a delay condition on the worker, pushes it to the stack, sees the stack postpone it by 10 seconds, then opens the gate and sees it run.

Pipeline
Script
admin
#1. The settlement worker;
script create exe "tuto.as.settle" false 1
	(param
		(var "[batch]" {true} "Payment batch" is_null:false is_empty:false "B-20261101")
	;)
	"Settle a payment batch"
{
	sequence increment "tuto_as_settled";
} "1";
sequence add "tuto_as_settled" 0;
sequence add "tuto_as_bank_file" 0;
#2. Not before the bank file, check again 10 seconds later;
script set delay "tuto.as.settle.exe" 10 sec {
	== (sequence get current "tuto_as_bank_file") 1;
};
-> "[gen]" (string substring (script generate delay "tuto.as.settle.exe") 39);
#3. Push it now and wait until the stack postpones it;
-> "[pid]" (stack (date now) "tuto.as.settle.exe" "[batch]" "B-20261101");
json load "tuto_as_p" (stack get [pid]);
-> "[dt0]" (json select "tuto_as_p" "/dtexe");
-> "[i]" 0;
while (and (< [i] 40) (equal (json select "tuto_as_p" "/dtexe") [dt0])) {wait "1000"; ++ "[i]"; json load "tuto_as_p" (stack get [pid]);};
-> "[dt1]" (json select "tuto_as_p" "/dtexe");
#4. The bank file arrives: open the gate;
sequence update "tuto_as_bank_file" 1;
-> "[j]" 0;
while (and (< [j] 45) (== (sequence get current "tuto_as_settled") 0)) {wait "1000"; ++ "[j]";};
json load "tuto_as_p" (stack get [pid]);
-> "[out]" (concat "delay: " [gen] [_n_] "planned " [dt0] ", condition false, postponed to " [dt1] [_n_] "gate open, settled=" (sequence get current "tuto_as_settled") " at " (string substring (json select "tuto_as_p" "/dtclosed") 0 19));
#5. Cleanup;
stack delete_closed_id [pid];
json unload "tuto_as_p";
sequence remove "tuto_as_settled";
sequence remove "tuto_as_bank_file";
script delete "tuto.as.settle.exe";
[out]
Result
mentdb
delay: script set delay "tuto.as.settle.exe" 10 sec {
	== (sequence get current "tuto_as_bank_file") 1;
};
planned 2026-11-01 17:20:19, condition false, postponed to 2026-11-01 17:20:29
gate open, settled=1 at 2026-11-01 17:21:00
Go further
  • The delay type can be sec, min, hour, day, month or year: script set delay "..." 1 hour {...}.
  • The condition can test a file with file exist or a parameter with parameter get value.
executed on MentDB

Check cron expressions before deploying jobs

A deploy script contains several cron patterns written by hand. The developer reads the cron help, then tries each pattern on a probe job inside a try block and reports the valid ones and the scheduler error for the others.

Pipeline
Script
admin
#1. A reminder from the help: the fields of a cron expression;
-> "[help]" (string regexp_extract (job help) "Day of week[^\n]*" 0);
#2. A no-op script for the probe job;
script create exe "tuto.as.noop" false 1
	(param
	;)
	"Probe for cron checks"
{
	1;
} "1";
#3. Try each pattern on a probe job, inactive;
-> "[patterns]" "0 30 2 * * ?|0 15 10 ? * MON-FRI|0 0/5 8-18 * * ?|0 0 25 * * ?|0 0 12 * * MON";
-> "[report]" "";
for (-> "[k]" 1) (<= [k] (atom size [patterns] "|")) (++ "[k]") {
	-> "[p]" (atom get [patterns] [k] "|");
	try {
		job add "tuto_as_probe" "tuto.as.noop.exe" [p] false;
		job remove "tuto_as_probe";
		-> "[v]" "valid";
	} {
		-> "[v]" (string regexp_extract [err] "Sorry.*valid\." 0);
	} "[err]";
	-> "[report]" (concat [report] [p] " -> " [v] [_n_]);
};
-> "[left]" (job exist "tuto_as_probe");
script delete "tuto.as.noop.exe";
concat "help: " [help] [_n_] [report] "probe job left: " [left]
Result
mentdb
help: Day of week  YES  1-7 or SUN-SAT  , - * ? / L #
0 30 2 * * ? -> valid
0 15 10 ? * MON-FRI -> valid
0 0/5 8-18 * * ? -> valid
0 0 25 * * ? -> Sorry, the job pattern 0 0 25 * * ? is not valid.
0 0 12 * * MON -> Sorry, the job pattern 0 0 12 * * MON is not valid.
probe job left: 0
Go further
  • Hours go from 0 to 23, and day of month and day of week cannot both be set: one of them is ?.
  • The same try block works for job update before changing a production cron.
executed on MentDB

Run a job on one node of a cluster

On a cluster a nightly job must run on one node only. The developer registers the job, routes it through the cluster execution script, checks the record, then removes the routing and the job. The job is added inactive, so nothing runs.

Pipeline
Script
admin
#1. The nightly script and the cluster execution script;
script create exe "tuto.as.consolidate" false 1
	(param
	;)
	"Consolidate the daily figures"
{
	1;
} "1";
-> "[cs]" "cluster.1n.job_execution.exe";
-> "[has]" (script exist [cs]);
#2. At 02:30, inactive, routed through the cluster script;
job add "tuto_as_consolidate" "tuto.as.consolidate.exe" "0 30 2 * * ?" false;
job set cluster_script "tuto_as_consolidate" [cs];
json load "tuto_as_j" (job show);
-> "[routed]" (concat (json select "tuto_as_j" "/tuto_as_consolidate/scriptName") " at " (json select "tuto_as_j" "/tuto_as_consolidate/pattern") " via " (json select "tuto_as_j" "/tuto_as_consolidate/cluster_script") ", activate=" (json select "tuto_as_j" "/tuto_as_consolidate/activate"));
#3. Single server again: remove the routing, then the job;
job set cluster_script "tuto_as_consolidate" null;
json load "tuto_as_j" (job show);
-> "[back]" (json select "tuto_as_j" "/tuto_as_consolidate/cluster_script");
job remove "tuto_as_consolidate";
json unload "tuto_as_j";
script delete "tuto.as.consolidate.exe";
concat "cluster script present: " [has] [_n_] "routed: " [routed] [_n_] "after reset: cluster_script=" [back] ", job exists: " (job exist "tuto_as_consolidate")
Result
mentdb
cluster script present: 1
routed: tuto.as.consolidate.exe at 0 30 2 * * ? via cluster.1n.job_execution.exe, activate=0
after reset: cluster_script=, job exists: 0
Go further
  • With a cluster script the scheduler runs execute <cluster script> "[scriptname]" <job script>.
  • job scheduler status tells whether the scheduler of this node is running.
executed on MentDB

Audit your own jobs and generate their redeploy script

Before moving a project to another server, the developer lists only the jobs of the project (prefix tuto_as_), says which ones are active, checks the scheduler and generates the update request of each job.

Pipeline
Script
admin
#1. The project has three jobs, one inactive;
script create exe "tuto.as.crm_sync" false 1
	(param
	;)
	"Synchronise the CRM"
{
	1;
} "1";
job add "tuto_as_crm_hourly" "tuto.as.crm_sync.exe" "0 0 * * * ?" true;
job add "tuto_as_crm_nightly" "tuto.as.crm_sync.exe" "0 0 3 * * ?" true;
job create "tuto_as_crm_weekend" "tuto.as.crm_sync.exe" "0 0 6 ? * SAT" false;
#2. Only the jobs of the project, with their state;
json load "tuto_as_all" (job show);
json load "tuto_as_ids" (json fields "tuto_as_all" "/");
-> "[mine]" "";
-> "[redeploy]" "";
for (-> "[i]" 0) (< [i] (json count "tuto_as_ids" "/")) (++ "[i]") {
	-> "[id]" (json select "tuto_as_ids" (concat "/[" [i] "]"));
	if (string starts_with [id] "tuto_as_crm_") {
		-> "[mine]" (concat [mine] [id] " " (json select "tuto_as_all" (concat "/" [id] "/pattern")) " activate=" (json select "tuto_as_all" (concat "/" [id] "/activate")) [_n_]);
		-> "[redeploy]" (concat [redeploy] [_n_] (job generate update [id]));
	};
};
#3. Active jobs of the server and the scheduler;
json load "tuto_as_act" (job show activate);
-> "[act]" (json count "tuto_as_act" "/");
-> "[inact]" (string regexp_count (job show activate) "tuto_as_crm_");
-> "[sched]" (job scheduler status);
#4. Cleanup: take the active jobs out of the scheduler, then remove them;
job pause "tuto_as_crm_hourly";
job pause "tuto_as_crm_nightly";
job remove "tuto_as_crm_hourly";
job remove "tuto_as_crm_nightly";
job remove "tuto_as_crm_weekend";
json unload "tuto_as_all";
json unload "tuto_as_ids";
json unload "tuto_as_act";
script delete "tuto.as.crm_sync.exe";
concat [mine] "jobs in the scheduler: " [act] ", of the project: " [inact] " (the two active ones are scheduled as soon as added)" [_n_] "scheduler: " [sched] [_n_] "redeploy:" [redeploy]
Result
mentdb
tuto_as_crm_hourly 0 0 * * * ? activate=1
tuto_as_crm_weekend 0 0 6 ? * SAT activate=0
tuto_as_crm_nightly 0 0 3 * * ? activate=1
jobs in the scheduler: 13, of the project: 2 (the two active ones are scheduled as soon as added)
scheduler: Running...
redeploy:
job update "tuto_as_crm_hourly" "tuto.as.crm_sync.exe" "0 0 * * * ?" true;
job pause "tuto_as_crm_hourly";
job resume "tuto_as_crm_hourly";
job update "tuto_as_crm_weekend" "tuto.as.crm_sync.exe" "0 0 6 ? * SAT" false;
job pause "tuto_as_crm_weekend";
job resume "tuto_as_crm_weekend";
job update "tuto_as_crm_nightly" "tuto.as.crm_sync.exe" "0 0 3 * * ?" true;
job pause "tuto_as_crm_nightly";
job resume "tuto_as_crm_nightly";
Go further
  • Sort the ids with json sort to get a stable redeploy file.
  • Never stop the scheduler to change one job: pause it with job pause.
  • An active job stays in the scheduler until it is paused: job pause before job remove.
executed on MentDB

A job that only queues work in the stack

A fast cron must not do heavy work itself. The job script only pushes a worker run to the stack every 3 seconds; the stack runs the workers at its next cycle. The script counts pushes and finished workers, then cleans the closed runs.

Pipeline
Script
admin
#1. The worker and the light job script that queues it;
script create exe "tuto.as.rebuild" false 1
	(param
		(var "[slot]" {true} "Time slot to rebuild" is_null:false is_empty:false "2026-11-01 17:00:00")
	;)
	"Rebuild the cache of one time slot"
{
	sequence increment "tuto_as_rebuilt";
} "1";
script set stack "tuto.as.rebuild.exe" 0 5 false;
script create exe "tuto.as.enqueue" false 1
	(param
	;)
	"Queue a cache rebuild"
{
	sequence increment "tuto_as_queued";
	stack (date now) "tuto.as.rebuild.exe" "[slot]" (date now);
} "1";
sequence add "tuto_as_queued" 0;
sequence add "tuto_as_rebuilt" 0;
#2. The cron queues every 3 seconds, for 7 seconds;
job add "tuto_as_enqueue" "tuto.as.enqueue.exe" "0/3 * * * * ?" true;
wait "7000";
job pause "tuto_as_enqueue";
job remove "tuto_as_enqueue";
-> "[q]" (sequence get current "tuto_as_queued");
-> "[r0]" (sequence get current "tuto_as_rebuilt");
#3. The stack runs them at its next cycle;
-> "[i]" 0;
while (and (< [i] 40) (< (sequence get current "tuto_as_rebuilt") [q])) {wait "1000"; ++ "[i]";};
-> "[out]" (concat "queued by the job: " [q] ", rebuilt when the job stopped: " [r0] [_n_] "rebuilt by the stack about " [i] " s later: " (sequence get current "tuto_as_rebuilt"));
#4. Cleanup;
-> "[out]" (concat [out] [_n_] "closed runs purged: " (stack delete_closed_script "tuto.as.rebuild.exe"));
sequence remove "tuto_as_queued";
sequence remove "tuto_as_rebuilt";
script delete "tuto.as.enqueue.exe";
script delete "tuto.as.rebuild.exe";
[out]
Result
mentdb
queued by the job: 2, rebuilt when the job stopped: 1
rebuilt by the stack about 28 s later: 2
closed runs purged: 2
Go further
  • The job stays fast even if the rebuild takes minutes: the stack limits its parallel runs.
  • Use script set delay on the worker to skip a slot until its data is complete.
executed on MentDB

A frequent job that works only in business hours

A polling job fires every 2 seconds, but the partner API may be called only from Monday to Friday between 08:00 and 19:00. The job script checks the time window with date functions, counts the runs that worked and the runs that were skipped.

Pipeline
Script
admin
#1. The job script decides itself if it may work now;
script create exe "tuto.as.poll_partner" false 1
	(param
	;)
	"Poll the partner API in business hours only"
{
	-> "[h]" (date hour (date systime));
	if (and (== (date is_weekend (date sysdate)) 0) (and (>= [h] 8) (< [h] 19))) {
		sequence increment "tuto_as_polls";
	} {
		sequence increment "tuto_as_skipped";
	};
} "1";
sequence add "tuto_as_polls" 0;
sequence add "tuto_as_skipped" 0;
#2. Every 2 seconds for 7 seconds;
job add "tuto_as_poll_partner" "tuto.as.poll_partner.exe" "0/2 * * * * ?" true;
wait "7000";
job pause "tuto_as_poll_partner";
job remove "tuto_as_poll_partner";
#3. What the job did;
-> "[out]" (concat "now: " (date now) ", day of week=" (date day_of_week (date sysdate)) ", weekend=" (date is_weekend (date sysdate)) ", hour=" (date hour (date systime)) [_n_] "runs that polled: " (sequence get current "tuto_as_polls") ", runs skipped: " (sequence get current "tuto_as_skipped"));
#4. Cleanup;
sequence remove "tuto_as_polls";
sequence remove "tuto_as_skipped";
script delete "tuto.as.poll_partner.exe";
[out]
Result
mentdb
now: 2026-11-01 17:51:37, day of week=7, weekend=1, hour=17
runs that polled: 0, runs skipped: 4
Go further
  • The cron itself can hold the window: 0/2 * 8-18 ? * MON-FRI.
  • Keep the check in the script when the window comes from a parameter: parameter get value.
executed on MentDB

A sampling job and statistics on its rolling window

To size the JVM before a heavy import, a job samples the used memory and the CPU of the JVM every second into a node, keeping a rolling window of 10 samples. The script then removes the job and computes the statistics of the window with an alert threshold.

Pipeline
Script
admin
#1. The sampler: one JVM sample per run, kept in a node;
node create "tuto_p4m_samples";
node iobject "tuto_p4m_samples" / mem "[]" ARRAY;
node iobject "tuto_p4m_samples" / cpu "[]" ARRAY;
script create exe "tuto.p4m.sampler" false 1
	(param
	;)
	"Sample the JVM memory and CPU"
{
	#used/max/total in MB, keep the used part;
	node iarray "tuto_p4m_samples" /mem (atom get (metric current mem jvm) 1 "/") INT;
	node iarray "tuto_p4m_samples" /cpu (metric current cpu jvm) NUM;
	#A rolling window of 10 samples;
	if (> (node count "tuto_p4m_samples" /mem) 10) {
		node darray "tuto_p4m_samples" /mem 0;
		node darray "tuto_p4m_samples" /cpu 0;
	};
} "1";
#2. Every second, active at once;
job add "tuto_p4m_sampler" "tuto.p4m.sampler.exe" "0/1 * * * * ?" true;
wait 8500;
job pause "tuto_p4m_sampler";
job remove "tuto_p4m_sampler";
#3. Statistics on the window;
-> "[mem]" (string regexp_replace (node select "tuto_p4m_samples" /mem) "\s+" "");
json load "rx_p4m_st" (stat summary [mem]);
-> "[cpu]" (string regexp_replace (node select "tuto_p4m_samples" /cpu) "\s+" "");
-> "[peak]" (json select "rx_p4m_st" /max);
-> "[out]" (concat "samples: " (json select "rx_p4m_st" /n) ", job still there: " (job exist "tuto_p4m_sampler") [_n_] "JVM used MB " [mem] ": mean " (math round (json select "rx_p4m_st" /mean) 1) ", median " (json select "rx_p4m_st" /median) ", min " (json select "rx_p4m_st" /min) ", max " [peak] [_n_] "CPU JVM max: " (json load select "rx_p4m_cpu" (stat summary [cpu]) /max) [_n_] "alert: " (if (> [peak] 400) {"memory above 400 MB"} {"none"}));
json unload "rx_p4m_st";
json unload "rx_p4m_cpu";
node delete "tuto_p4m_samples";
script delete "tuto.p4m.sampler.exe";
[out]
Result
mentdb
samples: 10, job still there: 0
JVM used MB [98,106,115,123,131,139,155,190,198,287]: mean 154.2, median 135, min 98, max 287
CPU JVM max: 4.7
alert: none
Go further
  • job add ... true schedules at once: no job resume is needed before the first sample.
  • Plot the window with plot line to see the garbage collector saw tooth.

Also in Programming

MB
MQL beginner
Variables, operators, if, loops and your first try/exception: learn MQL step by step.
10 recipes
MD
MQL developer
Atom lists, data types, constants, translations, session variables and error patterns.
10 recipes
BW
Backend & web service developer
Typed scripts, execute / call / include, generated calls and URLs, parameters and logs.
10 recipes
DT
Date & time developer
Calendars, business days, time zones, ISO and epoch, durations, quarters and week numbers.
10 recipes
SE
String & encoding developer
Cleaning, case styles, regex, URL/HTML/Base64 encodings, number bases and encryption.
10 recipes
DV
Data validation developer
IBAN, BIC, SIRET, Luhn, email, IP, UUID, JSON and date checks gathered in a validation report.
10 recipes
JD
JSON & document store developer
In-memory JSON documents, persistent nodes and sequences: build, walk, sort, clean up.
10 recipes
SD
Script developer
Full script lifecycle in the MQL editor: typed parameters, read back, generate, patch, deploy, copy, grant, delete.
10 recipes
EM
Execution modes
execute, call, include, sub_include, parallel, stack: which environment, which checks, which logs.
11 recipes
WS
Web service developer
A small REST resource with get, post, put and delete scripts: validation, JSON answers, codes, grants, URLs and API docs.
10 recipes
AD
Async developer
Asynchronous processing with the stack: push runs now or later, priorities and parallel limits, errors and replays, flows and cleanup.
10 recipes
ED
Event developer
Event-driven scripts: file watchers that push each file event to the stack, validation, archiving, errors and safe restarts.
10 recipes
CC
Configuration & connections
Parameters (private, described, locked, deployed), environment variables, sessions and connections used by your scripts.
12 recipes
VD
Versioning & deployment
Group your scripts, commit, compare, roll back, export, import and package a release.
10 recipes
DE
Debugging & error handling
Coded errors with try/exception, logs with correlation ids, timing, metrics and defensive checks.
10 recipes
SD
SQL developer in MQL
Connections, DDL and DML with sql encode, transactions, cursors, parse, and exports to JSON, CSV, Excel and PDF on a real local database. Run the recipes in order: the first one creates the tuto_db_h2 database.
10 recipes
CD
CRUD & data API developer
Generate SCRUD scripts from a table, patch and install them, write typed read and write APIs, check data quality and manage connections per environment. Uses the tuto_db_h2 database of the SQL developer recipes; the last recipe removes it.
10 recipes
WA
Web application developer
Create a web app, its host name, pages, ajax forms, menu and grants, then remove it all.
10 recipes
AI
Algorithms in MQL
Sorting, searching, recursion, data structures and number algorithms: MQL is a real programming language.
10 recipes
CF
Control flow
if, if force, case, switch, mode, for, while, repeat, break, continue, parallel and synchronized on real cases.
10 recipes
TM
The MQL language in depth
Data types and null, booleans, comments, variables and scope, eval and mql blocks, coded errors and try.
10 recipes
SU
Screen & UI developer (sajax)
Build the screens of MentDB web apps in MQL: Bootstrap grids, forms and every control, ajax buttons, alerts, refreshes and charts.
10 recipes