Rosamunda
Rosamunda

Reputation: 14980

How to run cron in a secure way? (getting this warning: "Using a password on the command line interface can be insecure")

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?

Upvotes: 3

Views: 6994

Answers (1)

ToBe_HH
ToBe_HH

Reputation: 716

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.

Upvotes: 3

Related Questions