I have made a shell script on my red hat server that needs to be run every minute. My script is located in /media. I have edited the crontab like so:
* * * * * /media/statusshellscript.sh
My script is definitely in the location above and I know that 5 stars means run every minute.
oh.. and my script definintely works! because when I do a ./statusshellscript it works fine. Here is my script anyway, it basically just runs a php script I made which made life easier.
#!/bin/bash
# Script to execute the PHP Script
cd ~
cd /media/PHPServerTest
php -f index.php
Crontab is doing absolutely nothing at the moment. Not sure what to try next?
Also.. permissions shouldn't be a problem as i've done chmod 777 statusshellscript.
if its not running though cronjob but by command its working fine then there can be two reasons
1) you never made your file executable , that you can resolve my using the command
sudo chmod +x filename
2) your path is not correct , for finding absolute path you can use command
realpath(filename)
if realpath is not already installed it will mention you a command how to install it
by checking these points it should work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With