Jump to content
The Corroboree

Archived

This topic is now archived and is closed to further replies.

Torsten

For the techies: What's a cron job

Recommended Posts

I kinda know what it is, but I don't know how to do them. My admin interface lets me set cron jobs 'the easy way'. Timings etc are just click-on menus. But the 'command line' is what I haven't got the foggiest about.

The obvious thing I would like to do is to set a cron job to send the full forum backup to another server every few days. The advantages of this should be quite obvious

I've got almost 10gig in storage available to me on various current and defunct servers, so I might as well use it for something good

Share this post


Link to post
Share on other sites

A cron job is a scheduled task. In other words, anything that you can type at a command prompt, you can do via cron. But to use it you need some understanding of the underlying OS (I assume a UN*X varient, although there are cron ports for Win32).

Usually, one writes a shell script to do the task. For a backup, for example, you can use a script to do whatever it is you want to do with the database: you could write it to mass-media, or you could do a network copy to another host -- that way if you're server crashes you still have a relatively recent copy.

My guess is that the board back-ends to MYSQL. If this is the case, the script that you

would write would probalby:

perform an SQL dump of the database

copy the dump to another host (maybe though scp)

copy and media files (pictures, etc) that you let people upload.

etc.

Share this post


Link to post
Share on other sites

this forum doesn't run on a database (other things on this site do though). What I was hoping to do was to copy the forum directory from one server to another (both unix).

There is already a back up program on my server that can do the sending, but it doesn't have scheduling.

I have no idea how to write scripts. It sems that to use cronjobs I would need to know this, right?

Share this post


Link to post
Share on other sites
Guest electro

configuring cron tasks ...

http://linux-rep.fnal.gov/RHL-7.2-CG-HTML/.../cron-task.html

"There is already a back up program on my server that can do the sending, but it doesn't have scheduling."

how do you usually run it ?

does it ask you questions as it runs or does it just backup (like where to back up to and what to back up - or is this pre configured)

if it is simply run without asking questions then you might get away without a script and just throw in the path and file to be executed into cron .. eg /root/backupprog/backupprog

(maybe - im not 100% sure about this so doublecheck or try it - i havent used nix in aaaaaages :) )

(assuming that you can run the backup program by moving to /root/backupprog and run it by typing backupfile or ./backupprog)

I have no idea how to write scripts. It sems that to use cronjobs I would need to know this, right?

- shellscripts are just what you type at the command line, just set out in a file so that bash (or your shell) it executes it for you ...

(mind this example, its been ages since ive used nix)

eg when i want to connect to a samba server and see the files in it i usually jump to my commandline and type :

cd /usr/home/network

smbmount /remoteipaddress/share /usr/home/network/remoteipshare

if i wanted a script that did just that, i would make a text file, save it( as for example /usr/home/network/networkscript.sh) and type eactly what i typed above, with each command on its own line and #!/bin/sh on the first line by itself.

so

#!/bin/sh

cd /usr/home/network

smbmount /remoteipaddress/share /usr/home/network/remoteipshare

to schedule the machine to do this hourly i would add the line /usr/home/network/networkscript.sh to the hourly section of the cron file .

how to write a shell script

http://vertigo.hsrl.rutgers.edu/ug/shell_help.html

this is an example of a remote backup using cron and simple scripting to backup across a ssh session

http://madpenguin.org/Article1505.html

Share this post


Link to post
Share on other sites

:o

They don't have a smiley for 'way over my head'

Actually, this explanation should get me started. I'm bound to have more questions though after digesting it all.

The backup script asks where I want to back up to. It then gives me choices of either sending e-mail, sending another server/ftp or backing it to a backup folder on this server. obviously the latter option is not what i want. I'll play around with the back up function and the scrips first and then get back to this thread.

Share this post


Link to post
Share on other sites
Guest electro

this is exactly what you want ...

scheduled compressing of contents of a folder to a tar or tar.gz file, then ftping them to another server :)

http://www.ubbdev.com/db/cgi/ultimatebb.cg...=2;t=000038;p=0

it is a tutorual that first lets you compress your files with the tar command (similar to zip in windows)

then it shows you how to send the files using ftp to another ftp server (you may have to alter this depending on if u can install this software described on the server or not - if you have to use the existing software on the server [if its different] obviously the commands will be slightly different. there should be man pages on your server to document the commands though.

Share this post


Link to post
Share on other sites

×