脚本未在服务器上执行的问题

问题描述 投票:0回答:1

我在 cron 上编写了 script.sh,但它不起作用。

感谢您的帮助

我尝试记录脚本 我无法读取日志,因为它说权限被拒绝。 我尝试给予 debian 该文件的所有权。如果我手动执行它确实有效。我试图查看脚本是否仍在执行,但没有。

python server ftp debian sh
1个回答
0
投票

要解决权限被拒绝错误,请使用

chmod +x
为脚本可执行文件授予权限,然后对于 crontab,您可以使用
crontab -e
对其进行编辑,您应该得到如下所示的内容:

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

然后您可以添加脚本:

* * * * * /path/to/your/script.sh

如果您不知道如何管理时间,这里有几个例子:

0 12 * * *  # runs the script at 12:00 PM every day
*/5 * * * * # runs the script every five minuts
0 * * * *   # runs every hours

如果您仍然遇到问题,请分享您的 crontab 条目以获取更具体的帮助。

© www.soinside.com 2019 - 2024. All rights reserved.