38

I have a simple shell script that just checks the contents of a directory and if anything was added during the day makes a copy of it to a backup folder. I'd like to execute this script at the end of each day (let's assume at 23:55).

The system(Debian) which this scripts reside on it, is always on (kind of server)

How can I do that?

N..
  • 906
  • 7
  • 23
Sina Sh
  • 1,177
  • 3
  • 15
  • 24

5 Answers5

58

To add a crontab job, type the following command at a UNIX/Linux shell prompt:

$ sudo crontab -e

Add the following line:

1 2 3 4 5 /path/to/script

where

1: Minutes (0-59)
2: Hours (0-23)
3: Days (1-31)
4: Month (1-12)
5: Day of the week(1-7)
/path/to/script - your own shell script

In your case it would be:

55 23 * * * /path/to/yourShellScript
Kurt Van den Branden
  • 11,995
  • 10
  • 76
  • 85
34

You want to edit your crontab file using

crontab -e

Then you want to add

55 23 * * * COMMAND TO BE EXECUTED

for more info look at this

Simson
  • 3,373
  • 2
  • 24
  • 38
Parttimereaper
  • 593
  • 5
  • 16
4

I'm anything, but a linux expert, but a quick Google search conjured up this:

watch -n <your time> <your command/script>

This should do the trick. For more information, check this out: http://www.linfo.org/watch.html

4

sudo crontab -e

55 23 * * * some_shell_script.sh
algor
  • 404
  • 2
  • 8
3

Check out the Cron task scheduler built in to Debian. Simply add an entry for your script to your crontab file (see: https://help.ubuntu.com/community/CronHowto).

citysurrounded
  • 664
  • 4
  • 8