|Subject:||Re: [O]  Run org-babel src block periodically|
|Date:||Thu, 7 Jan 2016 23:44:13 -0800|
This is kind of close to what you want I think (at least it updates
every 5 seconds for me, 5 times before it stops). You might adapt it to
do what you want.
This is the block to run periodically.
top -o "cpu" -ncols 4 -l 1| head -n 15
Sun Jan 3 17:28:27 EST 2016
Processes: 225 total, 2 running, 3 stuck, 220 sleeping, 1110 threads
Load Avg: 1.20, 1.51, 1.55
CPU usage: 5.0% user, 22.50% sys, 72.50% idle
SharedLibs: 14M resident, 12M data, 0B linkedit.
MemRegions: 57263 total, 3092M resident, 72M private, 450M shared.
PhysMem: 6508M used (1098M wired), 1246M unused.
VM: 588G vsize, 1067M framework vsize, 6471076(0) swapins, 6831574(0) swapouts.
Networks: packets: 190809878/201G in, 277243826/231G out.
Disks: 11873268/180G read, 10075469/265G written.
PID COMMAND %CPU TIME
96378 com.apple.InputM 0.0 00:00.26
96376 AppleSpell 0.0 00:00.68
96015 head 0.0 00:00.00
This function will update that block. We increment a counter and cancel the timer when it is exceeded.
(defun update-src-block (fname src-name N)
"Update the src-block named SRC-NAME in the file FNAME upto N times."
(if (> *counter* N)
(progn (cancel-timer *timer*)
(message-box "Done with timer"))
(with-current-buffer (find-file-noselect fname)
We use a global var for the counter and timer.
(setq *counter* 0)
(setq *timer* (run-with-timer
: [nil 22153 41074 708648 5 update-src-block ("/Users/jkitchin/blogofile-jkitchin.github.com/_blog/blog.org" "time-string" 5) nil 0]
Giri Prashanth writes:
> I would like to run a org-src block code periodically, is there any
> property for org-blocks for such repeated execution.
> For example if I want to watch the tail of a file periodically every 1 min
> for next 1 hour, I would like to set a property like repeat for times to
> repeat and keep the org file auto updated
> #+BEGIN_SRC shell :repeat 60 :repeat-every 60sec
> tail -n 10 file
> Thank you,
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
|[Prev in Thread]||Current Thread||[Next in Thread]|