Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Cronjob每小时运行一次_Linux_Cron - Fatal编程技术网

Linux Cronjob每小时运行一次

Linux Cronjob每小时运行一次,linux,cron,Linux,Cron,我已经编写了一个小的bash脚本来清除日志(比如脚本名为clearLogs.sh) 我的任务:每小时运行bash脚本以清除日志 到目前为止我所做的:我已经为我的bash脚本创建了一个符号链接,并将其放置在/etc/cron.hourly中 example -> cd /etc/cron.hourly ln -s /home/sam/clearLogs.sh clearLogs.sh 现在,一个小时过去了,但是日志还没有被删除。如果我独立运行脚本,它将按预期工作。你们

我已经编写了一个小的bash脚本来清除日志(比如脚本名为clearLogs.sh)

  • 我的任务:每小时运行bash脚本以清除日志
  • 到目前为止我所做的:我已经为我的bash脚本创建了一个符号链接,并将其放置在/etc/cron.hourly中

    example -> cd /etc/cron.hourly    
    ln -s /home/sam/clearLogs.sh  clearLogs.sh   
    

现在,一个小时过去了,但是日志还没有被删除。如果我独立运行脚本,它将按预期工作。你们能告诉我我做错了什么吗

1.in clearLogs.sh添加行:RUN\u PATH=/you/script/PATH cd$RUN\u PATH

2.cat“***/1***/you/script/path/clearLogs.sh”>>$HOME/crontab.txt

3.crontab$HOME/crontab.txt


4.crontab-l,查看所有crontab作业

缩小我的问题范围,我想知道在cron.hourly目录中创建符号链接是否是一个可行的解决方案?在
/etc/cron.d/crontab
中是否有
01****root/bin/run parts/etc/cron.hourly
?或者类似的东西?显示
/etc/cron.d/crontab的内容
/home/sam/clearLogs.sh的权限是什么?@h4bo,我没有在crontab上做任何事情,我认为通过在cron.hourly中创建脚本的符号链接可以满足purpose@John,权限是777我想,项目2应该是
echo
,而不是
cat