Cherryware Cherryware
Products   Blog   Forum



Scheduler 3 the Scriptable Scheduler 3 the Scriptable
Start page
Description
Screen shots
Download
Freeware license
Plugins
Script examples
Support
Awards
   

Examples

 

1. Folder backup

Scenario :

  1. Create folder (if it does not exists)
  2. ZIP folder "incoming" to this folder
  3. Delete ZIPs that older than 7 days

{
string folder = "d:\backups";

string command = "7z.exe a backup_of_" + day(2) + "." + month(2) + "." + year(4) + ".7z -r d:\incoming\*";

mkdir(0, folder);
cp(command, folder);
wipeOldFiles(folder + "\*.*", 7);
}

Note 1 : Each time script running you get files
backup_of_09.01.2007.7z
backup_of_10.01.2007.7z
backup_of_11.01.2007.7z
... , etc

Note 2 : 7-Zip is a free file archiver with high compression ratio.
See http://www.7-zip.org/
7-Zip

 

2. mySql backups and sends backup file via EMail

Scenario :

  1. Create mySql dump
  2. Archive dump
  3. Send archived dump to "boss@server.com"

{
string fileName = hour(2) + "-" + min(2) + "_" + 
             day(2) + "." + month(2) + "." + year(4);

string dumpName =  fileName + ".dmp";
string archiveName =  fileName + ".7z";

string workingFolfer = "d:\temp";

string backupCommand = "mysqldump --all-databases 
		--user=root --password=qwerty 
		--result-file=" + dumpName;
		
string packCommand = "7z.exe a " + archiveName + " " + dumpName;

mkdir(0, workingFolfer);
cp(backupCommand, workingFolfer);
cp(packCommand, workingFolfer);

sndmaila(
    "dbadmin@server.com", 
    "boss@server.com", 
    "login", "password", 
    "smtp.server.com", "25", 
    "The last DB dump", 
    "See attachment", 
    workingFolfer + "\" + archiveName);
}
		

... and you will get archived DB dumps (named 14-52_11.01.2007.7z, 15-52_11.01.2007.7z, ... etc) in the mailbox every time script running

 

3. Nightly disk F: defragmenting

Scenario :

  1. Launch Windows disk defragmentor
  2. Turn computer off

{
cp("defrag f: -f -v >d:\defragmenting_f_report.txt", "");
poweroff();
}

 

4. Download big file

Scenario :

  1. Launch downloader "wget" to get file "big_file.zip" from the server "www.server.com"
  2. Turn computer off

{
string dwn = "d:\downloads";
mkdir(0, dwn);
cp("wget.exe http://www.server.com/files/big_file.zip", dwn);
poweroff();
}

Note : this example for demostrating purpose only

 

5. Cleanup temporary folder

Scenario :

  1. Wipes temporary files (7 days old) in folder "c:\windows\temp"
  2. Show message "Folder SOME_FOLDER has been cleaned."

{
string folderToBeCleaned = "C:\WINDOWS\Temp";
wipeOldFiles(folderToBeCleaned, 7);
remind("Folder " + folderToBeCleaned + " has been cleaned.");
}


Copyright © 2007 Cherryware. All rights reserved.