Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a PHP script completely on server side

I'm having a problem where putty gets regularly disconnected. So, when I run a PHP script from the terminal, it always gets interrupted. The script is supposed to run several hours, so I'm not having any luck with it.

How can I completely run this from the server side? I'm reading about cron jobs, but I'm having a hard time understanding at this time. Is there any alternative to cron for what I need?

I have several script PHP files that need to be run, one by one, or perhaps two at a time. Any ideas?

like image 338
musicliftsme Avatar asked Dec 08 '22 23:12

musicliftsme


1 Answers

You don't need to leave it run in a cron job - you can just run the php script inside a screen.

Simply type;

screen php /path/to/myphpscript.php

A screen will continue running even after you disconnect from PuTTY. If you need to check up on it, you can use;

screen -r

To re-attach yourself to this process, and view any output.

like image 187
Eoghan Avatar answered Dec 17 '22 23:12

Eoghan