B
B
Bur Ov2016-11-30 21:25:11
linux
Bur Ov, 2016-11-30 21:25:11

How to run php in screen with one command?

How to run php script in screen with one command?
It is necessary that with the help of one command, the command php -f test.php > file.log is executed in the already created screen window.
Is it possible?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philipp, 2016-11-30
@burov0798

https://www.gnu.org/software/screen/manual/screen....

screen -S YourScreenSessionName -p 0 -X stuff "$(printf "php src/workers/myworker.php\r")"

######

-S YourScreenSessionName говорит, что имя вашей сессии будет YourScreenSessionName
-p 0 устанавливает номер окна, в котором будет запущена команда
-X stuff утверждает, что нужно выполнить команду stuff
stuff принимает команду "$(printf "php src/workers/myworker.php\r")"  из буфера 
         и печатает ее внутри сессии
$(printf "php src/workers/myworker.php\r")  выполняет роль вызова, 
        который напечатает php src/workers/myworker.php в консоли  
        и \r нажмет Enter

For example, running the converter
#!/usr/bin/env bash

echo "Starting converter"
screen -dmS converter
screen -S converter -p 0 -X stuff "$(printf "php src/workers/converter.php\r")"

F
FanatPHP, 2017-03-27
@verdex

About why the request is not executed, you should not ask your uncle from the street, but your database . Only she knows for sure.
The uncle from the street can only tell you how to ask the database correctly .
Therefore, we change the connection code to
And naturally we get an error
In which it is written in black and white that the database does not like the word index.
we go to the list of reserved words and make sure that this is the way it is
And then we begin to wonder why the author uses backticks in phpmyadmin, but not in PHP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question