php - bash.sh 运行 cron 的权限被拒绝

标签 php linux bash shell cron

如何在此处使用 bash 脚本运行 cron。我按以下方式和此处进行了错误操作。我想知道如何在 ubuntu 中执行此操作。我现在对它感到震惊

bash.sh 文件

#!/bin/bash
cd /var/www/Controller
/usr/bin/php post.php

在 crontab -e 中

* * * * * /home/samitha/bash.sh >> /home/samitha/log/cron.log 2>&1

但现在我得到以下错误

/bin/sh: 1: /home/samitha/bash.sh: Permission denied

我将如何修复它?我做错了什么?

最佳答案

您也可以尝试以下解决方案:

chmod +x post.php
chmod +x bash.sh
echo "* * * * * /home/samitha/bash.sh >> /home/samitha/log/cron.log 2>&1" >> cronjob

chmod +x cronjob

/etc/init.d/crond start  #redhat based servers like centos
/etc/init.d/cron  start  #debian based servers like ubuntu

crontab cronjob

关于php - bash.sh 运行 cron 的权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21646551/

相关文章:

php - 使用 Xpath 获取第一个祖先

php - 使用 Mysql 查找即将到来的生日

linux - 加入多播组时需要 PORT 还是只需要 IP?

python - 从 bash 脚本执行带有 "import requests"的 python 脚本

linux - 用于删除旧文件版本的 bash 命令/脚本

linux - 如何在终端上顺序打开文件?

php - CDbCommand::fetchColumn() failed: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active

php - 如何使用 PHP 在 xml 中传递 ä

python - 如何增加使用 'timeout' 命令运行的进程的超时限制

linux - RHEL/apache 上的 QApplication/QThread 崩溃(__get_tls_addr 返回 0)