Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 562

How to make dune run in crontab?

$
0
0

There’s a simple demo project js101,

bin/dune:

(executable
 (name main)
 (modes js)
 (preprocess (pps js_of_ocaml-ppx))
 (libraries js_of_ocaml js_of_ocaml-ppx))

bin/main.ml:

open Js_of_ocaml

let () =
  let console = Js.Unsafe.pure_js_expr "console" in
  let log_func = Js.Unsafe.get console "log" in
  let message = Js.string "Hello, JavaScript!" in
  Js.Unsafe.fun_call log_func [| Js.Unsafe.inject message |]

For some reason, we need to run it in crontab, so here’s the testjs.sh:

rm -rf /home/ubuntu/todel/js101/_build/;
cd /home/ubuntu/todel/js101/;
dune build;
cp /home/ubuntu/todel/js101/_build/default/bin/main.bc.js /home/ubuntu/todel/;
echo "done";

Here’s the crontab:

*/5 * * * * sh /home/ubuntu/todel/testjs.sh >> /home/ubuntu/todel/testjs.log

It seems that the script been triggered success with:

$ cat testjs.log 
done
done

However, there no main.bc.js file generated by the crontab.

~/todel$ ls
js101  testjs.log  testjs.sh

But when I run the script from terminal, it does there:

~/todel$ sh testjs.sh 
done                  

~/todel$ ls
js101  main.bc.js  testjs.log  testjs.sh

4 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 562

Trending Articles