Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

610
Views
Permission denied with bash.sh to run cron

How to run a cron with bash script here.What i did as follows and here with errors.I want to know how to do that in ubuntu.I was struck with it now

bash.sh file

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

In crontab -e

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

But now i getting following error

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

How will i fix it ? what i did wrong ?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

you can try the following solution as well:

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
over 4 years ago · Santiago Trujillo Report

0

The user executing that cron (the one who executes cron -e) doesn't have proper rights for executing that script. That is: either the script lacks the execution flag, or it's not possible to reach it because some of its ancestor directories lack the execution flag.

over 4 years ago · Santiago Trujillo Report

0

The problem could be that your user does not have the rights to execute the file.

First you set the execution flag for your script

chmod +x /home/samitha/bash.sh

Then you should check the permissions for the php file with

ls -lah /var/www/Controller

If neither your usergroup nor your username shows up, you have to run the script with superuser rights or change its permissions.

First way would be put your entry in

sudo crontab -e

or the second one would be (which I would not recommend, as everyone would be allowed to execute the script by calling your site)

 chmod a+x /var/www/Controller/post.php
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!