Cron Jobs & Persistent Processes

From DreamHost
Jump to: navigation, search

Every account that has shell access on our servers has the ability to run shell commands.

You can also set up a "crontab" which will automatically run a shell command you specify at the times you specify.

We do have some policies regarding acceptable processes you may run on a shared hosting shell account. It is important you read these and abide by them or you will be in jeopardy of having your account terminated!

What is a cron job?

A cron job is simply a command you normally run from a shell window (i.e. telnet or ssh) that is periodically run at times you specify. It's a pretty standard feature of all unix operating systems, and we allow our shell users to use it!

May I run a cron job?

Yes you may, if you have a shell account on our server!

Of course, the restrictions on background processes apply to processes started via your crontab just as any other persistent process, so be sure to keep those in mind!

Do you know how to use crontab?

How do I set up a cron job?

Via the "crontab" command from the shell.

crontab -l will show you your currently set up cron jobs on the server.

crontab -r will delete your current cron jobs.

crontab -e will allow you to add or edit your current cron jobs by using your default text editor to edit your "crontab file".

Note, vi has a bug in it and will not work to edit your crontab! We recommend nano (which is just like pico), which is the default editor anyway!

Your crontab includes all the cron jobs you'd like, with one cron entry per line. A cron entry looks like this:

45 2 * * *     /home/user/
  • The first number is the minute of the hour for the command to run on.
  • The second number is the hour of the day for the command to run on.
  • The third number is the day of the month for the command to run on.
  • The fourth number is the month of the year for the command to run on.
  • The fifth number is the day of the week for the command to run on.

Here are some examples to help you learn the syntax for the numbers:

  • 32 * * * * : will be run every hour on the 32nd minute.
  • 12,42 * * * * : will be run twice an hour on the 12th and 42nd minutes.
  • */15 */2 * * * : will be run at 0:00, 0:15, 0:30, 0:45, 2:00, 2:15, 2:30, ...
  • 43 18 * * 7 : will be run at 6:43pm every Sunday.

Once you've made changes to the file using nano use CTRL + O and then press enter to save the file.

What is your persistent (background) process policy?

We define persistent/background processes as any unix user's command running non-interactively. That is, it runs while you aren't actively sitting there interacting with it through a shell window.

Firstly, we reserve the right to kill any user process on a shared server without warning or prior notification at our discretion. This doesn't apply on a private server, we don't restrict your processes there, only your memory limit you set does.

We don't just do this capriciously though! We do this if the process is in any way adversely affecting the smooth functioning of your shared server. Of course if you have a dedicated server you can run whatever (LEGAL) processes you'd like, you should just be prepared for the consequences they may have on your machine.

  • IRC-related persistent processes of any kind (including, but not limited to, bots, bouncers, etc.) are STRICTLY PROHIBITED, and are in violation of our TOS.
  • BitTorrent-related processes are not allowed.
  • Streaming Audio or Video servers of any kind are not allowed on shared hosting servers.
  • Voice chat or VoIP servers like Asterisk, Ventrilo and TeamSpeak are not permitted.
  • Game servers (CounterStrike, WoW, BF2, etc...)
  • Running programs via cron is allowed provided you don't use excessive system resources.

If you want to set something up and have any questions just ask our friendly tech support team, they don't bite. :)