<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://forum.ubuntu-fr.org/extern.php?action=feed&amp;tid=1089551&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Forum Ubuntu-fr.org / [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
		<link>http://forum.ubuntu-fr.org/viewtopic.php?id=1089551</link>
		<description><![CDATA[Les sujets les plus récents dans [résolu] commande fonctionne dans un terminal pas dans cron.]]></description>
		<lastBuildDate>Sat, 03 Nov 2012 08:23:11 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11372451#p11372451</link>
			<description><![CDATA[<p>Mais de rien !<br />Quand un script fonctionne dans le terminal et pas dans cron, c&#039;est souvent une histoire de variables d&#039;environnement.<br />Après, le truc c&#039;est que les variables d&#039;environnement sont pas forcément toutes initialisées par le .bashrc...<br />Bon week-end !</p>]]></description>
			<author><![CDATA[dummy@example.com (Postmortem)]]></author>
			<pubDate>Sat, 03 Nov 2012 08:23:11 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11372451#p11372451</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11370741#p11370741</link>
			<description><![CDATA[<p>slt<br />j&#039;ai mis dans le script<strong> savemysql.sh</strong> ce que tu m&#039;as indiqué</p><div class="codebox"><pre><code>#!/bin/bash
exec &gt; /tmp/log_mysql.log 2&gt;&amp;1
. $HOME/.bashrc
echo &quot;Lancement sauvegarde à $(date &#039;+%H:%M:%S&#039;)&quot;
sudo /usr/sbin/automysqlbackup
echo &quot;Fin sauvegarde à $(date &#039;+%H:%M:%S&#039;)&quot;</code></pre></div><p>et merci pour ton aide <img src="http://forum.ubuntu-fr.org/img/smilies/tongue.png" width="15" height="15" alt="tongue" /></p>]]></description>
			<author><![CDATA[dummy@example.com (lagirardiere)]]></author>
			<pubDate>Fri, 02 Nov 2012 22:49:37 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11370741#p11370741</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11370641#p11370641</link>
			<description><![CDATA[<p>Salut,<br />Petite question, par curiosité, quel est le contenu du script qui fonctionne du coup dans ton cron ??</p>]]></description>
			<author><![CDATA[dummy@example.com (Postmortem)]]></author>
			<pubDate>Fri, 02 Nov 2012 22:35:35 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11370641#p11370641</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11362161#p11362161</link>
			<description><![CDATA[<p>slt<br />Merci Postemortem pour ton aide<br /> J&#039;ai résolu mon probleme je me suis rendu compte que la sauvegarde s’était effectuer ce matin a 6h30 au même moment&#160; qu&#039;une autre tache (pas indispensable d’ailleurs) programmée dans cron ,je l&#039;ai supprimé et relancé mon script <strong>savemysql.sh</strong> et la tout roule .</p>]]></description>
			<author><![CDATA[dummy@example.com (lagirardiere)]]></author>
			<pubDate>Fri, 02 Nov 2012 08:40:12 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11362161#p11362161</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11353061#p11353061</link>
			<description><![CDATA[<p>Il ne faut pas lancer en mettant sh devant !<br />Fais comme ceci :<br />Contenu du script /usr/local/bin/savemysql.sh :</p><div class="codebox"><pre><code>#!/bin/bash
exec &gt; /tmp/log_mysql.log 2&gt;&amp;1
echo &quot;Lancement sauvegarde à $(date &#039;+%H:%M:%S&#039;)&quot;
sudo /usr/sbin/automysqlbackup
echo &quot;Fin sauvegarde à $(date &#039;+%H:%M:%S&#039;)&quot;</code></pre></div><p>Ensuite, on rend le script exécutable par :</p><div class="codebox"><pre><code>chmod 755 /usr/local/bin/savemysql.sh</code></pre></div><p>Puis dans ton cron :</p><div class="codebox"><pre><code>0 2 * * * /usr/local/bin/savemysql.sh</code></pre></div><p>Si tu mets sh devant ton script, il est exécuté en sh et non en bash ; et sh ne connait pas exec alors que bash, si !</p><p>Édit :<br />Ensuite, poste tout le contenu de /tmp/log_mysql.log</p><p>Re-edit :<br />Essaie en mettant ceci dans le script :</p><div class="codebox"><pre><code>#!/bin/bash
exec &gt; /tmp/log_mysql.log 2&gt;&amp;1
. $HOME/.bashrc
echo &quot;Lancement sauvegarde à $(date &#039;+%H:%M:%S&#039;)&quot;
sudo /usr/sbin/automysqlbackup
echo &quot;Fin sauvegarde à $(date &#039;+%H:%M:%S&#039;)&quot;</code></pre></div><p>La ligne que j&#039;ai ajouté permet d&#039;appeler tes variables d&#039;environnement ; il faut bien l&#039;écrire ainsi :</p><div class="codebox"><pre><code>.&lt;espace&gt;$HOME/.bashrc</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Postmortem)]]></author>
			<pubDate>Thu, 01 Nov 2012 13:21:39 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11353061#p11353061</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352911#p11352911</link>
			<description><![CDATA[<p>je fais le&#160; point<br />lorsque je lance maintenant la commande <strong>sh /usr/local/bin/savemysql.sh</strong> avec cron j&#039;ai&#160; en retour dans le fichier log&#160; <strong>/tmp/log_mysql.log</strong></p><div class="codebox"><pre><code>-bash: exec: et : non trouvé</code></pre></div><p>et voici mon script <strong>savemysql.sh</strong></p><div class="codebox"><pre><code>#!/bin/bash
echo &quot;Lancement sauvegarde à $(date &#039;+%H:%M&#039;)&quot;

exec &gt; /tmp/log_mysql.log 2&gt;&amp;1

sudo /usr/sbin/automysqlbackup

exit 0 </code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (lagirardiere)]]></author>
			<pubDate>Thu, 01 Nov 2012 13:09:18 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352911#p11352911</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352761#p11352761</link>
			<description><![CDATA[<p>@postmortem<br />j&#039;ai supprimer l&#039;envoie de mail par cron après l’exécution d&#039;une tache .<br />et maintenant la commande <strong>tail /tmp/log_mysql.log</strong> me renvoi ceci</p><div class="codebox"><pre><code> exitq&gt; serveur@serveur[xxx.xxx.x.x]:~$</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (lagirardiere)]]></author>
			<pubDate>Thu, 01 Nov 2012 12:58:41 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352761#p11352761</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352751#p11352751</link>
			<description><![CDATA[<p>Ça créé le fichier /tmp/log_mysql.log au moins ?<br />Si non, rajoute une ligne juste sous exec dans le genre de :</p><div class="codebox"><pre><code>echo &quot;Lancement sauvegarde à $(date &#039;+%H:%M&#039;)&quot;</code></pre></div><p>Comme ça, on saura au moins si quelque chose se lance.</p>]]></description>
			<author><![CDATA[dummy@example.com (Postmortem)]]></author>
			<pubDate>Thu, 01 Nov 2012 12:57:48 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352751#p11352751</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352611#p11352611</link>
			<description><![CDATA[<p>@postmortem<br />oui rien de plus</p><p>@ piolet<br />pas de fichier log /var/log/</p><p><img src="http://forum.ubuntu-fr.org/img/smilies/sad.png" width="15" height="15" alt="sad" /></p>]]></description>
			<author><![CDATA[dummy@example.com (lagirardiere)]]></author>
			<pubDate>Thu, 01 Nov 2012 12:45:13 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352611#p11352611</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352351#p11352351</link>
			<description><![CDATA[<p>bonjour</p><p>tu as regardé dans la&#160; log ?<br />/var/log/cron</p>]]></description>
			<author><![CDATA[dummy@example.com (piolet)]]></author>
			<pubDate>Thu, 01 Nov 2012 12:11:22 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352351#p11352351</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352331#p11352331</link>
			<description><![CDATA[<p>Zut !!<br />Tu as essayé de lancer le script en cron avec la ligne exec &gt; ... histoire de voir s&#039;il y a des messages d&#039;erreur ?</p>]]></description>
			<author><![CDATA[dummy@example.com (Postmortem)]]></author>
			<pubDate>Thu, 01 Nov 2012 12:09:02 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352331#p11352331</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352271#p11352271</link>
			<description><![CDATA[<p>alors désolé, je crois que je peux pas t&#039;aider la dessus... <img src="http://forum.ubuntu-fr.org/img/smilies/hmm.png" width="15" height="15" alt="hmm" /></p>]]></description>
			<author><![CDATA[dummy@example.com (cracolinux)]]></author>
			<pubDate>Thu, 01 Nov 2012 12:00:26 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352271#p11352271</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352221#p11352221</link>
			<description><![CDATA[<p>merci pour vos réponses<br />@cracolinux et grigouille<br />j&#039;ai testé la commande avec cron en root mais pas mieux rien ne se passe.</p><p>@Posmortem<br />oui les commandes fonctionnent dans un terminal <br />pour la commande <strong>env | grep -i mysql</strong><br />je n&#039;ai aucun retour .<br /><img src="http://forum.ubuntu-fr.org/img/smilies/sad.png" width="15" height="15" alt="sad" /></p>]]></description>
			<author><![CDATA[dummy@example.com (lagirardiere)]]></author>
			<pubDate>Thu, 01 Nov 2012 11:54:34 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11352221#p11352221</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11350081#p11350081</link>
			<description><![CDATA[<p>Salut,<br />@grigouille :<br />Pas besoin de modifier le crontab root.<br />@lagirardiere :<br />Si tu fais un script bash (qui commence par #!/bin/bash), si tu le lances en mettant sh devant, il sera exécuté avec sh et non bash.<br />Mais je pense pas que ton problème vienne de ça. C&#039;est plutôt un souci de variables d&#039;environnement.<br />Ta commande fonctionne dans le terminal, c&#039;est bien ça ?<br />Donc, dans le terminal, où ta commande fonctionne, tape ceci et ajoute la liste des variables au début de ton script :</p><div class="codebox"><pre><code>env | grep -i mysql</code></pre></div><p>Cela va te donner une liste de variables d&#039;environnement liées à mysql. Il faudra les ajouter au début de ton script comme ceci :</p><div class="codebox"><pre><code>#!/bin/bash

export mysql_socket=xxxxxxx
export mysql_turlutu=yyyyyy

sudo /usr/sbin/automysqlbackup</code></pre></div><p>Puis dans ton cron :</p><div class="codebox"><pre><code>0 2 * * * /usr/local/bin/savemysql.sh</code></pre></div><p>Mais ça m&#039;étonne que tu doives utiliser sudo pour une commande mysql. Tu devrais pouvoir ajouter ton user dans le groupe qui va bien pour passer les commandes mysql sans sudo.</p><p>Edit :<br />Tu peux aussi mettre ceci au début de ton script, ainsi nous aurons les éventuels messages d&#039;erreurs dans le fichier /tmp/log_mysql.log :</p><div class="codebox"><pre><code>#!/bin/bash

exec &gt; /tmp/log_mysql.log 2&gt;&amp;1
export mysql_socket=xxxxxxx
export mysql_turlutu=yyyyyy

sudo /usr/sbin/automysqlbackup</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Postmortem)]]></author>
			<pubDate>Thu, 01 Nov 2012 09:43:56 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11350081#p11350081</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [résolu] commande fonctionne dans un terminal pas dans cron]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=11349861#p11349861</link>
			<description><![CDATA[<p>Il faut modifier la crontab de root :</p><div class="codebox"><pre><code>sudo crontab -e</code></pre></div><p>et mettre ta commande sans sudo </p><div class="codebox"><pre><code>0 2 * * * /usr/sbin/automysqlbackup</code></pre></div><p>C&#039;est dit dans la doc citée par cracolinux</p>]]></description>
			<author><![CDATA[dummy@example.com (grigouille)]]></author>
			<pubDate>Thu, 01 Nov 2012 09:28:20 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=11349861#p11349861</guid>
		</item>
	</channel>
</rss>
