crontab没有运行我的脚本 [英] crontab is not running my script

查看:195
本文介绍了crontab没有运行我的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是cron工作的新手.我阅读了帖子关于如何使用crontab编写cron作业. 所以我的crontab看起来像这样:

I'm new to cron jobs. I read a post on how to write a cron job with crontab. So my crontab looks like this:

1 * * * * /Users/apple/Desktop/wget/down.sh

这基本上意味着我想每分钟执行一次脚本: down.sh .现在脚本运行 手动罚款.该脚本是一个简单的程序,可以从Internet下载PDF:

which basically means that every minute i want to execute the script :down.sh. Now the script runs fine manually. The script is a simple program that downloads a PDF from the internet:

#!/bin/bash

wget -U Mozilla -t 1 -nd -A pdf "http://www.fi.usj.edu.lb/images/stories/HoraireS08/3eli.pdf" -e robots=off;

我不知道为什么一旦终端告诉我他正在安装新的crontab时,它不是每分钟运行一次.

I don't know why it's not running every minute once the terminal tells me that he's installing the new crontab.

有人可以帮我吗?

解决方案: 谢谢大家的帮助, mcalex 表示的语法应为 * */1 * * *路径/到/脚本 如果您希望每小时执行一次. cron作业正常工作,但是我的错误只是写权限,实际上是在执行wget命令时,应该将pdf文件写入当前的workind目录中(如果使用cron选项卡,则为系统目录).所以我只需在执行wget命令之前导航到Desktop目录即可解决我的问题,如下所示:

Solution: Thank you all for your help, the syntax as mcalex said should be * */1 * * * path/to/script if you want it to be executed every hour. The cron job was working normally.However my mistake was simply writing permissions, in fact while executing the wget command, it's supposed to write the pdf file in the current workind directory which is a system directory in case of the cron tab. so i solved my problem simply by navigating to the Desktop directory before executing the wget command like so:

cd /Users/apple/Desktop/wget

,然后做我想做的事. PS:我也应该包括wget命令的完整路径.

and then do whatever i want to do. PS: i should include the full path of the wget command too.

再次感谢大家的帮助:)

Thank you all for you help again:)

推荐答案

您有错字吗?看来您可能输入了错误的桌面?

Do you have a typo? It looks like you might have mis-typed Desktop?

另一件事是将运行脚本的输出重定向到文件,以便您可以看到正在发生的事情:

Another thing to do is to redirect the output of running the script to a file so you can see what's going on like this:

1 * * * */用户/苹果/停止/wget/down.sh >>/tmp/cron.out

1 * * * * /Users/apple/Destop/wget/down.sh >> /tmp/cron.out

,然后检出文件以查看发生了什么事.

and then check out the file to see what's going on.

这篇关于crontab没有运行我的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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