Friday, March 14, 2014

Trigger Script Every Minute/Day/Week with Crontab [Linux Ubuntu]

GOAL:  Trigger a script every 15 minutes.

SOLUTION:  
Cron = job scheduler in unix-type operating systems
Crontab = Cron Table file that configures shell commands to run on some schedule

STEPS to add script

1.  Write & Save a series of linux shell/bash commands to script.sh

nano script.sh

*PATHS MUST BE ABSOLUTE, (from root, i.e. /home/user/script.sh)*
Relative Paths Will Not Work (i.e. echo "hi" > test.txt;).  Must be echo "hi" > /home/user/test.txt;

2.  Open Cron

crontab -e

2.  Select 2 for nano (easiest linux file editor)

3.  Add to bottom of file:

#min hour day month weekday command
*/1   *    *    *    *      <command>
example
#Run Script.sh Every 15 minutes
#min hour day month weekday command
*/15   *    *    *    *     /home/user/script.sh

*preceding "sh" is not needed before the script path for cron*

STEPS to check cron status/error/log

1.  Check if cron is running

sudo status cron
2.  Open the system log file (for ubuntu)

nano /etc/rsyslog.d/50-default.conf

3.  Find the line that starts with: #cron.*  Uncomment that line to be:

cron.*

4.  Save the file (Ctrl + Z)

5.  Restart rsyslog

sudo service rsyslog restart

6.  Check cron log file

cat /var/log/cron.log

Also possible to see cron jobs with grep CRON /var/log/syslog
This didn't work for me for Ubuntu 12.04, which is why I wrote this post.

Reference








Go to End of File [Linux Nano]

Control + w + v

Jumps cursor to end of open file in terminal
REFERENCE

Linux Flavor & Version

Find Linux Flavor (Redhat, Ubuntu, etc) & Version from Terminal...

cat /etc/*-release

REFERENCE

Thursday, March 13, 2014

"this" in JavaScript

"this" in JavaScript = a referral to the parent object

TEST IT:
http://www.w3schools.com/js/tryit.asp?filename=tryjs_create_object2
adding & removing "this" was the easiest way for me to understand

EXAMPLE:
function OpenStudioModel(buildingData, runmanager) {
  this.model = new openstudio.model.Model();
  this.runManager = runmanager;
};

"this" is a replacement of OpenStudioModel function
"this" is the current instance of OpenStudioModel
"this" is adding functionality to OpenStudioModel function
"this" is short hand for OpenStudioModel.model & OpenStudioModel.runManager

REFERENCES
CodeSchool Definition of "this":  this keyword will automatically refer to the new instance of the class that is being made





Find Automated Logic WebCTRL Point Data for Web Services

Automated Logic (ALC) WebCTRL = controls software for buildings


STEPS 
to find Automated Logic’s WebCTRL point data to connect to Web Services

1.  Login to WebCTRL Website IP (must be using Internet Explorer web browser)

2.  GEO (bottom left corner)

3.  Click on one of the black icons under floor

4.  Points for Web Services = Any Yellow Point.  To see information behind the yellow points:
    Alt + Left Click on a point
    Note:  Right clicking does not work (screenshot below).  Global Modify shows up but is un-clickable.   

4.  Show Advanced

5.  Copy Geographic Location & Network Location

6.  Record & Repeat for each point of interest.

PURPOSE:  To connect a building's ALC WebCTRL to Lucid's Building Operating System, which can integrate each of these points into a more flexible and engaging building data overview.  

REFERENCES
These screenshots are only possible because of: 
Payam Delgoshaei, EEB Hub Data Scientist / Controls Engineer

Fix Blank Automated Logic (ALC) WebCTRL Interface in Internet Explorer

Automated Logic (ALC) WebCTRL = controls software for buildings
NOTE:  WebCTRL only works in Internet Explorer web browser.

PROBLEM
WebCTRL loads in your browser as a blank white screen, without the typical graphical user interface.  This is an Internet Explorer settings problem - it may be a result of a recent IE update.

SOLUTION = open local intranet security settings in Internet Explorer

STEPS 
1.  Click the Internet Explorer “Gear” (upper right corner), then, "Internet options" :
a.        

2.  Click “Security” tab, then, “Local Intranet”, then the “Sites” button:
a.        

3.  Click the “Advanced” button:
a.       

4.  Add the site you need (your WebCTRL IP):
a.       

You may need to disable requiring “HTTPS”:

5.  Go to WebCTRL login & images should re-appear.


REFERENCES
all IE settings credit goes to Corey Wilkinson of PSU AE
Payam Delgoshaei for troubleshooting with WebCTRL


Wednesday, March 12, 2014

Terminal Scroll Page Up in Mac

SHIFT + FN + ArrowUp (or ArrowDown)

To scroll up in mac's terminal without your mouse.
Specifically For:
- Terminal or iTerm
- Mac OS X

REFERENCE

Tuesday, March 4, 2014

Search Folder or File in Linux Terminal

GOAL:  Search or find a folder/directory/file in Linux through terminal command line. 

FOLDER
find / -type d -name FOLDER
or   find . -type d | grep FOLDER

FILE
find / -type f -name FILE
or  find . -type f | grep FILE

find = app on linux
/ = root folder directory
.  = current directory
-type d = directory/folder
-type f = file

NOTE:  These might take a while to show results.
REFERENCE

Saturday, March 1, 2014

Reroute Webpage

GOAL:  Reroute a webpage to another webpage.  To do this, just add the meta tag below inside of the head tags of your webpage.  

SOLUTION:
<html>
<head>
<meta http-equiv="Refresh" content="0; url=http://www.google.com"/>
</head>
</html>

Replace www.google.com with the webpage you want to reroute to.

If you're using Apache, save the text above into a file called index.html.  The web server will then reroute users to another website completely.