如何模拟环境的cron执行一个脚本? [英] How to simulate the environment cron executes a script with?

查看:306
本文介绍了如何模拟环境的cron执行一个脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常有几个问题,因为他们通常没有我的环境设置的cron如何执行脚本。有没有一种方法安装之前调用的bash(?)以同样的方式的cron没有,所以我可以测试脚本?

I normally have several problems with how cron executes scripts as they normally don't have my environment setup. Is there a way to invoke bash(?) in the same way cron does so I could test scripts before installing them?

推荐答案

添加到您的cron:

30 08 * * * env > ~/cronenv

它运行

后,做到这一点:

After it runs, do this:

env - `cat ~/cronenv` /bin/sh

这假定您的cron运行SH。我相信这是默认的。

This assumes that your cron runs sh. I believe this is the default.

这篇关于如何模拟环境的cron执行一个脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆