tâche cron

codis14

New Member
#1
bonjours .
voudriez vous me guider j'ai besoin de deux tâches cron j'ai 4 chemin théoriques qui ne fonctionne pas :
Bash:
/usr/local/bin/ea-php99 /home/survbskp/public_html/CAEN/mailer.php
/usr/local/bin/php /home/survbskp/public_html/CAEN/mailer.php
/usr/local/bin/php /home/survbskp/public_html/CAEN/reminder.php
  /usr/local/bin/ea-php99 /home/survbskp/public_html/CAEN/reminder.php.
quatre autres possible qui ne lancent pas mes tâche mais lisent les fichiers :
Bash:
/usr/local/bin/ea-php99 /home/survbskp/public_html/CAEN/scripts/mailer.sh
/usr/local/bin/php /home/survbskp/public_html/CAEN/scripts/mailer.sh
/usr/local/bin/php /home/survbskp/public_html/CAEN/scripts/reminder.sh
/usr/local/bin/ea-php99 /home/survbskp/public_html/CAEN/scripts/reminder.sh
voyez vous le problème?
 

PH-Gabriel

Moderateur
Membre du personnel
#2
Bonjour codis,

La commande sous le format php /home/USERNAME/chemin/vers/votre/fichier.php va fonctionner. Si votre fichier php affiche du texte (via "echo" par exemple), il est possible de configurer votre adresse email dans la section cron. De cette manière, vous allez recevoir la sortie de votre script par email chaque fois que le cron se lance.

Pour plus d'information sur les crons, allez sur notre documentation: https://docs.planethoster.com/guide...n-difference-entre-wget-ou-curl-ou-encore-php
 

codis14

New Member
#3
Bonjour

j'ai essayé de nombreux exemples pour mes tâche cron mais rien ne fonctionne.

vu certains sujet sur le forum peut êtres ai je besoin de rajouter quelque chose à ces ficher .

mailer.sh

#!/bin/bash
# project: eBrigade
# homepage: http://sourceforge.net/projects/ebrigade/
# version: 5.0

# Copyright (C) 2004, 2019 Nicolas MARCHE
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

# Add execution for this script in the crontab
# Used to defer some mail sending to this script, asynchronous
# Valid when thousands of mails need to be sent
# add execution of this shell script in the crontab
# example: send mails on every minute
# * * * * * /var/www/vhosts/mydomain.org/httpdocs/scripts/mailer.sh

EBDIR=`dirname $0`/..
export HTTP_HOST=`hostname`
cd $EBDIR
php ./mailer.php
-------------------------------------------------------------------------------------------------------------

mailer.php
<?php

# project: eBrigade
# homepage: http://sourceforge.net/projects/ebrigade/
# version: 5.0

# Copyright (C) 2004, 2019 Nicolas MARCHE
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

include_once ("config.php");

// script to be used by cronjob in command line. Or for test purpose in a browser
if(! defined('STDIN')) {
// for test purpose only
check_all(14);
}

// is mail system locked?
$query="select VALUE from configuration where NAME ='lock_mailer'";
$result=mysqli_query($dbc,$query);
$row=mysqli_fetch_array($result);
$LOCKED=intval($row["VALUE"]);

if ( $LOCKED == 0 and $mail_allowed == 1) {
// lock mail system
$query="update configuration set VALUE='1' where NAME ='lock_mailer' and VALUE=0";
$result=mysqli_query($dbc,$query);

$query="select ID, MAILDATE, MAILTO, SENDERNAME, SENDERMAIL, SUBJECT, MESSAGE, ATTACHMENT
from mailer";
$result=mysqli_query($dbc,$query);
$number=mysqli_num_rows($result);

$i=0;
while ( $row=mysqli_fetch_array($result)) {
$i++;
$ID=$row["ID"];
$MAILDATE=$row["MAILDATE"];
$MAILTO=$row["MAILTO"];
$SENDERNAME=$row["SENDERNAME"];
$SENDERMAIL=$row["SENDERMAIL"];
$SUBJECT=$row["SUBJECT"];
$MESSAGE=$row["MESSAGE"];
$ATTACHMENT=$row["ATTACHMENT"];

if ( $i == 1 ) {
echo date('Y-m-d H:i:s')." - Sending ".$number." mails by ".$SENDERNAME.". Subject: ".$SUBJECT."\n";
}

if ( $ATTACHMENT == "" ) $ATTACHMENT = "None";
$ret = mysendmail2($MAILTO,"$SUBJECT","$MESSAGE","$SENDERNAME",$SENDERMAIL, $ATTACHMENT);
$ret=0;
if ( $ret == 0 ) {
$query2="delete from mailer where ID=".$ID;
$result2=mysqli_query($dbc,$query2);
}

if ( $i == 100 ) { // pause 5 seconds every 100 mails
sleep(5);
$i=0;
}
}

$query="OPTIMIZE TABLE 'mailer'";
mysqli_query($dbc,$query);

// unlock mail system
$query="update configuration set VALUE='0' where VALUE='1' and NAME ='lock_mailer'";
$result=mysqli_query($dbc,$query);
}

mysqli_close($dbc);

?>


j'ai essayé /home/user/public_html/fichier/scripts/mailer.sh ça ne fonctionne pas
php /home/USERNAME/chemin/vers/votre/fichier.php ça ne fonctionne pas et de nombreux chemin rien ne fonctionne .

voudriez vous m'aider , merci
 
Haut