Проблема в том, что при запуске из консоли ./myapp окошки выводятся, а из крона - нет
Crontab (для юзера rj45):
*/5 * * * * DISPLAY=:0.0 /home/rj45/myapp
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "mysql.h"
#define DbHost "loaclhost"
#define DbUser "user"
#define DbPassword "password"
#define DbName "sdb"
MYSQL mysql;
MYSQL_RES *result;
MYSQL_ROW row;
int main(int argc, char * argv[])
{
char* query;
char* notify;
pid_t pid;
mysql_init(&mysql);
mysql_real_connect(&mysql, DbHost, DbUser, DbPassword, DbName, 0, NULL, 0);
mysql_query(&mysql, "SET CHARACTER SET 'utf8'");
asprintf(&query, "select firms.title, DATE_FORMAT(notes.date, '%%T'), notes.text from notes join firms on (notes.kod=firms.kod) where DATE(notes.date) = DATE(NOW()) and notes.date <= DATE_ADD(NOW(), INTERVAL 5 MINUTE) and notes.done=0 and notes.type=1 and notes.manager=%s order by notes.date desc limit %s", argv[1], argv[2]);
mysql_query(&mysql, query);
result = mysql_store_result(&mysql);
while((row = mysql_fetch_row(result))) {
asprintf(¬ify, "--text=\"Перезвонить в %s\n%s\n\nПримечание:\n%s\"", row[1], row[0], row[2]);
pid = fork();
if (pid == 0) {
execl("/usr/bin/zenity", "zenity", "--info", "--title=\"Напоминание\"", notify, NULL);
}
}
free(notify);
free(query);
mysql_free_result(result);
mysql_close(&mysql);
}
execl("/usr/bin/zenity", "DISPLAY=:0.0 zenity", "--info", "--title=\"Напоминание\"", notify, NULL);