阅读 48

shell运行python脚本,nodejs执行shell脚本

在项目中使用了定时执行shell命令的功能:

//runShell.js

const process=require (child _ process );

请求(colors );

module.exports=(sh,log=',callback ) }

罗格!=='? console.log (` [ shell log ] `.green,log ) : null;

console.log(`[ SH ]`.cyan,sh.cyan;

process.exec(sh,(err,sto )={

if(err ) {

console.log ` [ shell error ] `.red,err;

返回

}

罗格!=='? console.log ` [ shell log ] `.green,log,' success ' ) : null;

console.log(sto;

callback () )

() )

}

//壳牌. js

constasync=require(async );

constmoment=require('moment );

construn=require('./run ' );

请求(colors );

async.waterfall (甜杯子/p(next )={

console.log (' # # # # # export users # # # # # # ' );

console.log(starttime: (,moment ).format ) yyyy-mm-DDhh:mm:ss ) )

next (;

(,

(next )={

mongo import-h 127.0.0.1336027017-dxxx-c users-- file/var/www/XXX.JSON-- up sert ','导出文件'

(,

],(err )={

console.log(endtime: (,moment ).format (yyyy-mm-ddhh : mm : ss ) )

if(err ) {

console.log ` [ exportusersshellerror ] `.red,err;

}

() )


文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐