Welcome Guest ( Log In | Register )

Wanted - Cron-Job SQL/PHP Server guru
post Nov 7 2008, 02:00 PM
Post #1


Group: Chairman
Posts: 14062
Joined: 8-February 04
Member No.: 1

Amoungst our troops there must be someone who knows how to write Cron-jobs.

I'd like to set up the UMSF server to automate backups of the forum DB and attachments folder, but it's just a bit beyond me. It's a LAMP setup using Cpanel 11.

Anyone who has 'the knowledge' to help me out - let me know!

No pay, but you can have an UMSF subdomain to put stuff on ( like Mike has for MMB anims ) as a UMSF perk biggrin.gif


Go to the top of the page
+Quote Post
Start new topic
post Nov 7 2008, 05:27 PM
Post #2


Group: Members
Posts: 644
Joined: 23-December 05
From: Forest of Dean
Member No.: 617

Hi there! smile.gif

If it's a simple file copy (or compress, copy file off box, delete local copy) that'd be pretty trivial to do. PHP's probably not the ideal language to write the script in though, a tiny shell script is probably the best way to do it.

Viva software libre!
Go to the top of the page
+Quote Post
Fran Ontanaya
post Nov 7 2008, 07:24 PM
Post #3


Group: Members
Posts: 286
Joined: 22-September 08
From: Spain
Member No.: 4350

As imipak says, if it's just about copying files it's quite simple. I use a bash script to copy, zip, encrypt and upload my docs to an external server. For a five times per month backup, a simple script could look like this:

THEDAY=`date +%d`
THEDATE=`date +%m-%d`
if [ $THEDAY = 01 -o $THEDAY = 7 -o $THEDAY = 13 -o $THEDAY = 19 -o $THEDAY = 25 ] ;
zip -r ~/backups/backup-mydocs-$THEDATE.zip ~/folder/mydocs/
echo 'Backup finished. Closing...'
sleep 2

That zips everything in the folder '~/folder/mydocs/'. The old backups get overwritten after a year.

You can edit the cron with "crontab -e". I do my backups at 20:16 because I know the computer is on at that time. The line would look like this:

16 20 * * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,


Or you can use a script like this:

THEDATE=`date +%m-%d`
zip -r ~/backups/backup-mydocs-$THEDATE.zip ~/folder/mydocs/
echo 'Backup finished. Closing...'
sleep 2

And a cron like this, for the same effect:

16 20 1 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 7 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 13 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 19 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 26 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,

PS. I decline the subdomain offer.

"I can easily see still in my mind’s-eye the beautiful clusters of these berries as they appeared to me..., when I came upon an undiscovered bed of them... – the rich clusters drooping in the shade there and bluing all the ground" -- Thoreau
Go to the top of the page
+Quote Post

Posts in this topic

Closed TopicStart new topic


RSS Lo-Fi Version Time is now: 25th June 2018 - 08:32 AM
Please read the Forum Rules and Guidelines before posting.

Images posted on UnmannedSpaceflight.com may be copyrighted. Do not reproduce without permission. Read here for further information on space images and copyright.

Opinions expressed on UnmannedSpaceflight.com are those of the individual posters and do not necessarily reflect the opinions of UnmannedSpaceflight.com or The Planetary Society. The all-volunteer UnmannedSpaceflight.com moderation team is wholly independent of The Planetary Society. The Planetary Society has no influence over decisions made by the UnmannedSpaceflight.com moderators.
Unmannedspaceflight.com is a project of the Planetary Society and is funded by donations from visitors and members. Help keep this forum up and running by contributing here.