Daemon logging in Linux

Unix has had for a long while a special logging framework called syslog. Type in your shell man 3 syslog and you’ll get the help for the C interface to it. Some examples #include <stdio.h> #include <unistd.h> #include <syslog.h> int main(void) { openlog(“slog”, LOG_PID|LOG_CONS, LOG_USER); syslog(LOG_INFO, “A different kind of Hello world … “); closelog(); … Read more

Python script as linux service/daemon

Assuming your daemon has some way of continually running (some event loop, twisted, whatever), you can try to use upstart. Here’s an example upstart config for a hypothetical Python service: description “My service” author “Some Dude <blah@foo.com>” start on runlevel [234] stop on runlevel [0156] chdir /some/dir exec /some/dir/script.py respawn If you save this as … Read more

Run a shell script and immediately background it, however keep the ability to inspect its output

To ‘background’ a process when you start it Simply add an ampersand (&) after the command. If the program writes to standard out, it will still write to your console / terminal. To foreground the process Simply use the fg command. You can see a list of jobs in the background with jobs. For example: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)