
Un agent IA n est vraiment utile que s il travaille sans que vous ayez a le lancer manuellement. Voici comment planifier des taches automatiques : rapport matinal, surveillance de sites, backup nocturne, veille concurrentielle.
Methode 1 — Python schedule (la plus simple)
La bibliotheque schedule est parfaite pour planifier des taches dans votre script Python :
pip install schedule
import schedule, time, threading
def rapport_matinal():
print("Rapport du matin...")
# Votre logique agent ici
def check_emails():
print("Verification emails...")
def backup_nocturne():
print("Backup en cours...")
# Planification
schedule.every().day.at("08:00").do(rapport_matinal)
schedule.every(10).minutes.do(check_emails)
schedule.every().day.at("02:00").do(backup_nocturne)
schedule.every().monday.at("09:00").do(lambda: print("Rapport hebdo"))
# Boucle principale
while True:
schedule.run_pending()
time.sleep(60)
Methode 2 — Taches planifiees Windows
Pour que l agent demarre automatiquement au boot :
# PowerShell (en administrateur)
$action = New-ScheduledTaskAction -Execute "C:\chemin\python.exe" -Argument "-m app.main" -WorkingDirectory "C:\chemin\agent"
$trigger = New-ScheduledTaskTrigger -AtLogon
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -DontStopOnIdleEnd
Register-ScheduledTask -TaskName "MonAgentIA" -Action $action -Trigger $trigger -Settings $settings
Methode 3 — Cron (Linux/Mac)
# Editer le crontab
crontab -e
# Ajouter :
@reboot cd /home/user/agent && python -m app.main &
0 8 * * * cd /home/user/agent && python rapport.py
*/10 * * * * cd /home/user/agent && python check_emails.py
Methode 4 — Systemd (Linux, le plus robuste)
# Creer /etc/systemd/system/agent-ia.service
[Unit]
Description=Agent IA Autonome
After=network.target
[Service]
Type=simple
User=votre_user
WorkingDirectory=/home/user/agent
ExecStart=/usr/bin/python3 -m app.main
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
# Activer
sudo systemctl enable agent-ia
sudo systemctl start agent-ia
sudo systemctl status agent-ia
Architecture autopilot
Notre agent AgentBMax utilise un systeme d autopilot qui combine schedule + threading :
AUTOPILOT_TASKS = {
"briefing": {"schedule": "08:00", "action": rapport_matinal},
"email_check": {"interval_min": 10, "action": check_emails},
"site_monitoring": {"interval_min": 60, "action": check_sites},
"backup": {"schedule": "02:00", "action": backup},
"crypto_watch": {"interval_min": 30, "action": check_crypto},
}
for name, task in AUTOPILOT_TASKS.items():
if "schedule" in task:
schedule.every().day.at(task["schedule"]).do(task["action"])
elif "interval_min" in task:
schedule.every(task["interval_min"]).minutes.do(task["action"])
Materiel recommande
Un agent qui tourne 24/7 doit etre sur une machine fiable et econome : un mini PC Intel Core Ultra consomme 15W et suffit largement. Ajoutez un NAS pour le stockage des logs et backups.
