View Full Version : Cron Jobs
Jeffery67 04-15-2003, 05:57 PM Hey,
Anyone have any knowledge with cron jobs. I was thinking about making backups for my files with cron jobs and maybe a couple other things I might try.
aim Geesh Jeffery
icq 212601965
msn trunksman67@hotmail.com
email webmaster@riding-free.net
YUPAPA 04-15-2003, 06:08 PM I can help you, please let me know what's the problem :angel:
Jeffery67 04-15-2003, 06:39 PM Well i just need to figure out how to use them and whats the code and such.
YUPAPA 04-15-2003, 10:25 PM 1) You setup a crontab file... (i.e my_cron_tab_file) :)
2) Open my_cron_tab_file, you enter the date and time you want the script to run :angel:
* * * * * /bin/sh /root/myscript.sh
The first number means minute (0..59)
The second number means hour (0..24)
The third number means the day (1..31)
The forth number means month (1..12)
That means the script runs every minute every single day.
3) You save it and execute the command: crontab my_cron_tab_file :fork:
4) Check to see if your crontab exist execute: crontab -l :homer:
5) Done~ :fairy:
If you need a backup script, I already wrote one and you can see it @
http://scriptbox.yupapa.com
Click on 'Data Backup'
Jeffery67 04-15-2003, 11:01 PM can i do this with cpanel? Just go strait to making the file and setting the cron job up there.
YUPAPA 04-15-2003, 11:08 PM I think so... I don't have CPanel, I do it from SSH...
Jeffery67 04-15-2003, 11:20 PM where should i place the file? Just in my root directory?
YUPAPA 04-16-2003, 12:01 AM Anywhere you want
Jeffery67 04-16-2003, 12:14 AM ok well i am getting an error like this "backup.sh":2: bad day-of-month
errors in crontab file, can't install.
YUPAPA 04-16-2003, 12:30 AM I think I forgot to tell you about the weekdays... so sorry :(
It should be in this format :angel:
minute hour day month weekdays path to script
minute 0..59
hour 0..23
day 1..31
month 1..12
weekdays 0..6 (Sunday .. Saturday)
Show me your crontab file if you still get errors :fork:
Jeffery67 04-16-2003, 12:31 AM CRON JOB
40 0 * * *
command crontab backup.sh
cpanel is crazy umm let me see here is the thing descripted
minute 29
hour 0
day *
month *
weekday *
command crontab backup.sh
YUPAPA 04-16-2003, 12:34 AM no, not my script, the crontab file (i.e my_cron_tab_file)
Jeffery67 04-16-2003, 12:37 AM ok i changed it above i cant acual copy paste because cpanel just has me enter the info
YUPAPA 04-16-2003, 01:16 AM 40 0 * * * /bin/sh backup.sh
Sorry, I know nothing about CPanel :(... if you prefer to do it from shell, that's the way to do it :angel:
YUPAPA 04-16-2003, 01:20 AM After visiting the CPanel demo, there are two styles... go to Advanced UNIX Style and put 40 for min and 0 for hour... for command, put /bin/sh /full/path/to/your/backup.sh
the script will run @ 0:40 everyday
segment 04-16-2003, 03:45 AM The easiest way to edit your crontab file is to use:
crontab -e
from the command line as root. This will open up your text editor (vi, pico, etc) and you make changes, once you've saved them it'll update the cron jobs, so there's no need to run crontab my_cron_file or even worry about where the file is stored as that's all taken care of for your by cron.
Jeffery67 04-16-2003, 01:55 PM now its telling me /bin/sh: /home/riding-f/backup.sh: bad interpreter: Permission denied
Jeffery67 04-16-2003, 06:23 PM ok fixed that now no such file or direcotry
Jeffery67 04-16-2003, 11:07 PM humm confusing it says : : No such file or directory
i tried changing some thigns but it still ist working
darkie 04-18-2003, 08:38 PM few weeks ago I made a script to backup my clients their directory's. It backup's every night with cron. Maybe you could use this.
first make in a directory a few maps wich has the names off you client directory's
you could use this script for it
You only need to modify the paths
#!/usr/local/bin/bash
for i in `ls /home/web/clients/` ;
do
mkdir /disk2/backups/clients/$i
done
save as makedirs.sh and changemod it and run it
then the backup script.
#!/usr/local/bin/bash
for i in `ls /home/web/clients/` ;
do
tar cvpfz /disk2/backups/clients/$i/$i$(date +%Y%m%d).tar.gz /home/web/clients/$
done
save as backup.sh
then in your cron file pu this
# ClientBackup
1 01 * * * root /scripts/clientbackup.sh
know it executes the script 1 minit after 1 hour every night
sorry for my poor english,
and hope this have helped.
|