Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crontab that executes shell script every minute [closed]

Tags:

linux

shell

cron

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.

like image 533
rednaxela Avatar asked Jun 11 '26 04:06

rednaxela


1 Answers

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.

like image 97
akhter wahab Avatar answered Jun 13 '26 18:06

akhter wahab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!