According to Ubuntu’s Upstart website, “Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.” Basically, Upstart is an init daemon that replaces the /etc/init.d scripts. It comes with Ubuntu 6.10 and later, and it is also used in Fedora and Debian.
If you want to run your program with Upstart, you have to write a job for it. Jobs are defined in files placed in /etc/init with the .conf extension. The job will be named after the file it is defined in (without the .conf extension). The job definitions are written in plain text files (should not be executable).
/etc/init/greeenlog.conf
description "Logs keypresses, screenshots, clipboard data, and browsing history to a database." # Start when gnome starts start on started gdm stop on shutdown # Set any Environmental variables you need env DISPLAY=:0.0 exec /usr/local/greeenlog/main.pyw
After saving this job, you can go ahead and run it. No reboot is necessary. Here are the commands (assuming you have a job named greeenlog):
$ status greeenlog
greeenlog stop/waiting
status returns the last action performed on the job (start or stop) followed by the current state (running, sleeping, waiting, etc.) and the process ID (if any).
$ start greeenlog
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.61" (uid=1000 pid=2496 comm="start) interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
The start command tells Upstart to start the job, but what was that garbage I got for a response? Well, after getting some help, I realized that all I needed to do was add sudo:
$ sudo start greeenlog
greeenlog start/running, process 2943
You can also stop the service with the stop command.
I used the job defined above to run my personal keylogger as a service. However, It often would fail to start properly at boot. Running the service manually later with sudo start greeenlog would start the keylogger correctly, but what kind of shitty keylogger needs to be started manually? After two days of tinkering, I’ve learned that Upstart is not the right answer for startup applications that depend on GNOME or X, even if they do require root access. If want to run an application at boot that requires root access, you should try Run Application as Root at Startup instead.
You might notice that I defined an environment variable in my Upstart job. Upstart only provides baseline environment variables. Here are the variables that were provided to my job by default, captured in a Python dictionary with os.environ:
{'TERM': 'linux', 'PWD': '/', 'UPSTART_INSTANCE': '', 'UPSTART_JOB': 'greeenlog', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin'}
Janeth Kent
Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.
Related Posts
How To Use Varnish As A Highly Available Load Balancer On Ubuntu 20.04 With SSL
Load balancing with high availability can be tough to set up. Fortunately, Varnish HTTP Cache server provides a dead simple highly available load balancer that will also work as a…
Linux For Dummies: Permissions
In the previous articles I made a short introduction to the Unix world and in the following article I have dealt with the basic commands for the file system management. Today we are…
Linux for Dummies: Ubuntu Terminal
I introduced in the previous article, available here, the basic concepts concerning the Linux world. Today we are going to have a look to some basic operations that we can perform…
How to Make the Most of Technology in Your Business
If you’ve decided not to make use of the available technology in your business, you’ll soon find yourself falling behind the competition. More and more businesses are using technology to…
The Best RSS Readers for Ubuntu
Even if most of the tech experts actively claim that RSS (Rich Site Summary) is dead especially after Google Reader was discontinued 5 years ago but it isn’t yet as…
How to install Letsencrypt Certificates with Certbot in Ubuntu
In this article we will explain how to install, manage and configure the SSL Security certificate, Let's Encypt in NGINX server used as proxy. This certificate is free but does…
A Guide to Moving IT Services During an Office Relocation
Relocating a business from one office to another can be stressful. You can’t afford any loss of productivity and given that there are so many things that can go wrong,…
How to Set up a Fully Functional Mail Server on Ubuntu 16.04 with iRedMail
Setting up your own mail server from scratch on Linux is complex and tedious, until you meet iRedMail. This tutorial is going to show you how you can easily and…
GIMP 2.10 released: Features 32-bit support, new UI and A Ton Of Improvements
It's been over a half-decade since the GIMP 2.8 stable debut and today marks the long-awaited release of GIMP 2.10, its first major update in six years. And among other…
Setting Up SFTP on Ubuntu 16.04
I recently had a request to setup SFTP for a customer so they could manage a set of files in their environment through an FTP GUI. Being an avid user…
Install Java in Ubuntu 16.04
Java and the JVM (Java's virtual machine) are widely used and required for many kinds of software. This article will guide you through the process of installing and managing different…
ArangoDB, install and configure the popular Database in ubuntu 16.04
Introduction to ArangoDb, open source, NoSQL, multi-model database BigData seems to be getting stronger every day and more and more NoSQL databases are coming out to the market, all trying to position…