1

I have to set up a job manager for the console command that I have created. The console command needs from 20 - 30 minutes to finish. This console command is writing into the database multiple queries and let's assume that it can't be shrink-ed to a less time.

I have all created in Symfony2.8, but I am a really newbie using it. So I enter link description here

All I need is to run this command like a background task. Without touching the frontend of the application. Could anyone help me out ?

Ah, all right. This needs to be done regularly, but on a user/clients request.

2 Answers 2

2

It very much depends on what it needs to do.

Just run once it once-only? Login onto the server, use tmux or screen to keep something running, even if you disconnect, and then run the command (bin/console name-of-command).

Running regularly - put an entry into crontab for the user that needs to run it.

Without knowing what the script needs to do, and how often it would be done (if any), it's hard to say what the nexts steps could be.

Sign up to request clarification or add additional context in comments.

4 Comments

Sorry, for not mentioning in the question itself. This needs to be done regularly, but on user/clients request, from another server. We have two servers. One contain the CMS and on the second one is the frontend. From CMS server they want to call console command which I have built. Is it clearer at all ?
@FortuneSoldier is the command implemented in the CMS or frontend code? Are you wanting to call the command from the CMS or frontend or both?
Hey @malarzm, I have got this from the DtcQueueBundle. Going to check it up soon.
@FortuneSoldier you want to call the command from the CMS - noted. Where is the command code implemented: in the frontend code base or the cms code base?
1

You need The Process Component.

You can achieve php running in background the following way:

$builder = new ProcessBuilder();
$builder->setPrefix('/usr/bin/php'); // put your php executable here
$cmd = $builder->setArguments(['/full/path/to/php/file/you/want/to/run.php', 'argumentOne', 'argumentTwo'])
      ->getProcess()
      ->getCommandLine();

$process = new Process($cmd . '  > /dev/null 2>&1 &'); // async trick here
$process->run();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.