0

I am going crazy as not understanding what I am doing wrong.

I wrote this bash script to run a php script with nohup. It looks like this:

#!/bin/bash
nohup /usr/bin/php /opt/bitnami/nginx/html/folder/script.php $argv > fileoutput.txt 2>&1 &

when I run in in terminal as ./script.sh it does work, I can see the process running if I grep php and also my database updates.

Now I am trying to automate this process with crontab with this instruction:

43 * * * * /bin/sh /opt/bitnami/nginx/html/folder/script.sh

I am just changing the minute currently to test the automation as I will add a cycle of $argv to be executed when I manage to get this to work.

I have applied chmod 777 to the script.sh and now I really have no idea what else to fix.

Thanks in advance!

2
  • What is $argv and how is it set? it's unlikely that it will be in the cron execution environment. Do you see any errors in fileoutput.txt? – steeldriver Dec 2 '19 at 13:02
  • $argv is just a variable that you can write and updates the php script to then query the DB in my case. I see no errors as my problem is that the script doesn't even run. – Luke_V Dec 9 '19 at 5:07
0

The desktop's runtime environment differs from the cron runtime environment. Read man 5 crontab and run

(echo "=== set ===";set;echo "===env ==="; env | sort;echo "=== alias ===";alias)

in both environments, and compare the results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.