How to stop a Linux job after a certain time

Posted on in Categories Howto, Linux, Shell scripting last updated August 2, 2007

This article explains – controlling the duration of scheduled jobs (at and cron jobs) under Linux using nice shell script tricks:

Say you need to debug a pesky problem by running some traces for 30 minutes at midnight, or you would just like to use your Linux system as an alarm clock. This tip helps you stop jobs, such as those started with the cron and at capabilities, after the jobs have run for a certain time, or when some other criteria are met.

Linux tip: Controlling the duration of scheduled jobs

Getting Yesterdays or Tomorrows Day With Bash Shell Date Command

Posted on in Categories Howto, Linux, Shell scripting, Tips, UNIX last updated June 17, 2007

When invoked without arguments, the date command displays the current date and time. Depending on the options specified, date will set the date and time or print it in a user defined way. I’ve seen many sysadmin writing perl scripts for calculating relative date such as yesterdays or tomorrows day. You can use GNU date command, which is designed to handle relative date calculation such as:

  • 1 Year
  • 2 Days
  • 2 Days ago
  • 5 Years

Howto: Shutdown Linux Box Automatically

Posted on in Categories CentOS, Debian Linux, Gentoo Linux, Howto, Linux, Suse Linux, Sys admin, Tips, UNIX last updated October 2, 2005

You may wonder – why should I shutdown the Linux box box automatically? It depends upon your situation. For example, your downloading couple of tar balls and you want to go home. You can schedule a job to shutdown Linux after downloading is completed. Linux/UNIX/BSD/OS X comes with at and cron commands to automate task. Almost all common task can be automated using at command.