且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何建立一个cron作业运行可执行每隔一小时?

更新时间:2023-12-02 16:01:34

  0 * * * * CD folder_containing_exe&放大器;&安培; ./exe_name

应该工作,除非有别的东西,需要设置的程序来运行。

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

I logged in as root and typed crontab -e

Then I entered the following and saved the file.

0 * * * *  /path_to_executable

However, the cron job does not work.

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.