4

I have a problem when executing a shell command. The problem is that I would like to run a command exec('du -sh /var/www/backups/* > backups.log') but I would like to just press "START" and read backups.log later. Right now when I press the button I have to wait until it finishes, so the page waits until the script finishes.

2 Answers 2

5

Trying launching the process in the background by adding "&" like this:

exec('du -sh /var/www/backups/* > backups.log &');
Sign up to request clarification or add additional context in comments.

Comments

0

You can use AJAX for resolve this problem, no ? When the user click on start, execute your Php script. During that, you can do everything else.

1 Comment

It wouldn't be reliable. The ajax request will wait for the script to complete, which may take minutes, and the php script would likely terminate once the connection dropped (if the user left the page).

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.