如何设置 cron 作业以每小时运行一个可执行文件? [英] How to set up a cron job to run an executable every hour?

查看:14
本文介绍了如何设置 cron 作业以每小时运行一个可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置一个 cron 作业,该作业每小时运行一次使用 gcc 编译的可执行文件.

I need to set up a cron job that runs an executable compiled using gcc once every hour.

我以 root 身份登录并输入 crontab -e

I logged in as root and typed crontab -e

然后我输入以下内容并保存文件.

Then I entered the following and saved the file.

0 * * * *  /path_to_executable

但是,cron 作业不起作用.

However, the cron job does not work.

我看到当我输入 /...path_to_executable 时,我遇到了分段错误.我只能从它所在的文件夹中执行可执行文件.有什么办法可以解决这个问题吗?

I see that when I type /...path_to_executable I get a segmentation fault. I can only execute the executable from the folder it is located in. Is there a way I can solve this problem?

推荐答案

0 * * * * cd folder_containing_exe && ./exe_name

应该可以工作,除非需要设置其他程序才能运行.

should work unless there is something else that needs to be setup for the program to run.

这篇关于如何设置 cron 作业以每小时运行一个可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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