3

I've created a cronjob using cPanel.

Every a certain period of time it runs this php file that generates a backup:

<?php 
include $_SERVER['DOCUMENT_ROOT'].'conectar.php';

$filename='backup_cursos_'.date('d-M-y__H:i:s').'.sql';

$result=exec('mysqldump '.DATABASE.' --password='.PASS.' --user='.USER.' --single-transaction >/home/cursos/backups/'.$filename,$output);

if($output==''){/* no output is good */}
else {/* we have something to log the output here*/}

?>

The constants DATABASE, PASS and USER are stored in conectar.php file.

I'm getting this warning message every time the cron runs:

Warning: Using a password on the command line interface can be insecure.

I thought I was being secure adding the constants there, so my question is:

How do I run the cron job in a secure way?

Rosamunda
  • 14,620
  • 10
  • 40
  • 70

1 Answers1

3

See Suppress warning messages using mysql from within Terminal, but password written in bash script for details on that question. Basically: don't provide the password via command line but via settings.

ToBe_HH
  • 678
  • 6
  • 9