Run javascript script (.js file) in mongodb including another file inside js

前端 未结 5 522
攒了一身酷
攒了一身酷 2020-12-24 10:14

I want to write a long script for inserting and updating mongodb data.

  1. Is it possible to call external js file that contains the script?
  2. Is it pos
5条回答
  •  青春惊慌失措
    2020-12-24 11:04

    for running mutilple js files

    #!/bin/bash
    cd /root/migrate/
    
    ls -1 *.js | sed 's/.js$//' | while read name; do
         start=`date +%s`
         mongo localhost:27017/wbars $name.js;
         end=`date +%s`
         runtime1=$((end-start))
         runtime=$(printf '%dh:%dm:%ds\n' $(($runtime1/3600)) $(($secs%3600/60)) $(($secs%60)))
         echo @@@@@@@@@@@@@ $runtime $name.js completed @@@@@@@@@@@
         echo "$name.js completed"
         sync
         echo 1 > /proc/sys/vm/drop_caches
         echo 2 > /proc/sys/vm/drop_caches
         echo 3 > /proc/sys/vm/drop_caches
    done
    

提交回复
热议问题