linux – 从cron运行casper.js脚本

linux – 从cron运行casper.js脚本,第1张

概述我正在尝试通过cron运行casper.js脚本.当我手动运行脚本时,一切正常,但是当我通过cron运行它时,我得到以下错误: Traceback (most recent call last): File "/usr/local/bin/casperjs", line 46, in <module> status = subprocess.call(CASPER_COMMAND) Fi 我正在尝试通过cron运行casper.Js脚本.当我手动运行脚本时,一切正常,但是当我通过cron运行它时,我得到以下错误:

Traceback (most recent call last): file "/usr/local/bin/casperJs",line 46,in <module>   status = subprocess.call(CASPER_COMMAND) file "/usr/lib/python2.6/subprocess.py",line 480,in call   return Popen(*popenargs,**kwargs).wait() file "/usr/lib/python2.6/subprocess.py",line 633,in __init__   errread,errwrite) file "/usr/lib/python2.6/subprocess.py",line 1139,in _execute_child   raise child_exceptionOSError: [Errno 2] No such file or directory

我的crontab条目是:

30 9 * * * /usr/local/bin / casperJs lib / fsaupload.Js arg1 arg2 arg3

我也试过了

30 9 * * * python /usr/local/bin / casperJs lib / fsaupload.Js arg1 arg2 arg3

这给了我相同的结果.有任何想法吗?我猜它可能是路径问题,但不知道从哪里开始!

解决方法 您应该使用casper脚本的绝对路径,例如:

30 9 * * * /usr/local/bin/casperJs /absolute/path/to/lib/fsaupload.Js arg1 arg2 arg3

我的两分钱.

编辑:

好吧,这有点傻.您还可以通过设置PHANTOMJs_EXECUtable环境变量来设置phantomJs可执行文件的自定义路径:

$export PHANTOMJs_EXECUtable="/path/to/phantomJs"

然后像往常一样运行脚本:

/usr/local/bin/casperJs /absolute/path/to/lib/fsaupload.Js arg1 arg2 arg3

提示:如果您的crontab以另一个用户身份运行,请检查它是否可以访问phantomJs路径.

希望它有所帮助(并且有效).

再次编辑

等等,你得到的堆栈跟踪说你正在使用旧版本的CasperJs(例如,不再使用子进程模块).尝试使用更新的版本:)

总结

以上是内存溢出为你收集整理的linux – 从cron运行casper.js脚本全部内容,希望文章能够帮你解决linux – 从cron运行casper.js脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1027559.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存