Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

I'm toying around with building an application to display messages on the screen on a desired intervals.

I want to use cron to achieve that and I am considering my options. The most naive approach would be to print the commands directly into crontab. Is that a bad idea?

share|improve this question

No, it is not bad to have a long list in crontab. cron executes in minutes at the shortest time frame so it is not in real time but you can also have your notices in real time (see below).

As an alternative option you can also use cron to run 1 script that executes all your different crontab lines you otherwise would have included in your crontab where that file is executes or checks all the different options you want to get notices from. That would also be easier to maintain: if you need a new task you add it to your script and you can check if that job is flawed from the script itself (cron can be rather picky).

Might I also suggest you also have a look at creating an upstart job. This would be more the Ubuntu way. This way you create a daemon or service that you can start and stop from command linel. Plus it would make your notices real time instead of periodically.

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.

# Ubuntu upstart file at /etc/init/yourservice.conf

pre-start script
    mkdir -p /var/log/yourcompany/
end script

respawn limit 15 5

start on runlevel [2345]
stop on runlevel [06]

su - youruser -c "NODE_ENV=test exec /var/www/yourcompany/yourproject/yourservice.js 2>&1" >>  /var/log/yourcompany/yourservice.log
end script
share|improve this answer
1 Can you please give more evidence to the 256-line limit? I tested it at 300 lines (cron 3.0pl1-114ubuntu1) and no problem. And I also couldn't find any reference to the limit in the code. 2 Where in the sample upstart conf do you "make your notices real time"? – arrange Sep 11 '11 at 21:41
1. I have 2 examples included in my answer. Why do you need more? By the way. While trying to find even more proof: a default (user) cron also has a limit of 1024 chars per line (inclusing new lines). – Rinzwind Sep 11 '11 at 21:47
2. you do that by correctly coding the script that is your service. But that is not part of the question and I did not feel the need to include it (the part concerning upstart has already too much focus on it). – Rinzwind Sep 11 '11 at 21:49
The links probably don't apply to the Ubuntu version. I've tested both your assumptions (256 lines, 1024 chars), and they are both false (I used 300 lines and 2000 chars (mostly spaces between the numbers) per line in my crontab, and it worked as expected). There is a 1000 char limit per command though. – arrange Sep 11 '11 at 22:28
ok :) Ill edit it out but both topics do state it is about ubuntu (but maybe the just had buggy lines in their cron ;) ) – Rinzwind Sep 11 '11 at 22:32

Use gnome-schedule

enter image description here

It's intuitive, and it's easier to launch graphical applications from (doing that via cron requires some extra work) - just don't forget to mark the command as an X application one in the task configuration.


Sample use:

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.