Lajdák Marek
Lajdák Marek

Reputation: 3069

save exec() output to file in

I am executing gzip on a debian server via php using the exec() function.

gzip -1 -c file1.xxx > file1.gz  

Now I want to errors to be saved in some error.log.

  1. How I can set output to file?
  2. Is it better to use shell_exec()?

Upvotes: 0

Views: 385

Answers (1)

umläute
umläute

Reputation: 31274

to redirect stderr to a file, use the 2> redirector (2 is the file-handle for the stderr):

gzip -1 -c file1.xxx >file1.gz  2>error.log

(see also the REDIRECTION section man bash)

Upvotes: 1

Related Questions