Skip to content
Advertisement

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 ?

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement