Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I find how often a program (like firefox, teeworlds, thunderbird, etc.) has launched? I'm a Java programmer, so solutions that must be implemented programmatically are acceptable, and preferred.

share|improve this question
@UwePlonus it's not necessarily a programming question. If you ignore the extraneous first sentence in the OP it reads fine and is clear what they are after; a way to determine how many times a program has been launched in Ubuntu. – amc Jul 3 '13 at 13:22
@UwePlonus of course it's relevant! And so what if the solution also happens to work on Debian or others? Most "Ubuntu answers" work on Debian, it doesn't make them less relevant. – amc Jul 3 '13 at 13:25
@UwePlonus In ubuntu is there any way to get the times that a program has started to work? I`m not asking about java; my question is about ubuntu. – sorena Jul 3 '13 at 14:07
I think this is a great question about Ubuntu. But Have you checked in logs or stuff like that to see if it's logged there? is something generated every time the program has started, like a log or such, then you can just count the logs. - Just an idea... – Alvar Jul 3 '13 at 17:14
Perhaps someone knowledgeable about Zeitgeist could say if it can give this info? Btw, even from a programming standpoint, this sort of question tends to be OS-specific; techniques that work well in one GNU/Linux system might work poorly or not at all in another. (For example, if Zeitgeist will give this info, that would only help on OSes like Ubuntu where Zeitgeist is running in the default configuration, to have collected the information.) @UwePlonus Please keep in mind that "Development on Ubuntu" is explicitly on-topic. – Eliah Kagan Jul 3 '13 at 17:15

The only solution that I could come up with is to wrap the programs you're interested in. That of course is only feasible if the list of programs you want to observe is short enough.

Look after the command dpkg-divert. It lets you move files under package control aside while still being managed by the packaging system. Something like this could work:

# dpkg-divert --add --local --divert /usr/bin/firefox.mylogwrapped --rename /usr/bin/firefox

Then link a log script to the original path like

# ln -s /usr/local/bin/mylogwrapper /usr/bin/firefox

Inside that wrapper do whatever you need to do and then exec /usr/bin/firefox.mylogwrapped "$@". You can access the name of the originally called binary with the $0 environment variable.

Good luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.