up vote 0 down vote favorite
share [fb]

Can someone tell me how to to run a php script and output content and errors to a text file (using nohup) using csh?

link|improve this question
feedback

1 Answer

If your script has a hash-bang line (such as #!/bin/env php) at the top, you can run it directly like this:

nohup /path/to/your_script.php > /path/to/output.txt 2>&1 &

If not you can call the parser first with your script as an argument:

nohup php /path/to/your_script.php > /path/to/output.txt 2>&1 &

You didn't specifically mention you wanted to background the job, but usually when you nohup something you also want to background it, so I added the trailing & to the suggestions above.

link|improve this answer
thanks - it doesn't work though i get "ambigous output redirect"? – jimsmith Jun 10 at 15:25
Can you tell us what echo $SHELL tells you as well as the full command you are executing? – Caleb Jun 10 at 15:27
/bin/csh the full command is exactly as you have it – jimsmith Jun 10 at 15:29
Your question states you are using bash, but that is csh! I don't know enough about csh to give you an equivalent. Perhaps you should edit your question with that detail. Also it's not reasonable that the full command would be just as I have it because I have dummy paths. Seeing a full copy-paste from your terminal might helps us catch other mistakes. – Caleb Jun 10 at 15:31
Perhaps you should switch to bash or zsh? If you don't have specific reasons for using csh it might be easier for you to learn standard syntax that a majority of Linux folks use. – Caleb Jun 10 at 15:33
feedback

Your Answer

 
or
required, but never shown

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