Dynadot โ€” .com Transfer

Confused about a tutorial on hosting urchin.js locally | Assistance appreciated!

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch
Impact
158
I'm trying to understand this tutorial but i haven't got a clue what to do.

Create a shell script

Right... :blink:

How do i do this?
Copy the code into Notepad and...? :-/

The crontab

Add this to your crontab by typing crontab -e


What the ...:-/

Could someone guide me through this so i can use this set up for my site(s)?

If it's relevant to know i have a hosting account at Hostgator.

I want to use above set up for website(s) with a regular domain and on subdomains.

Which :great: could share some thoughts on this?
In such a way a programming illiterate like me can understand.

Thanks!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Looks like you need access to your server with that tut. Basically though all you need to do is save the .js file somewhere on your server. Then go to your control panel, if you have controlPanelX then it makes things a lot easier. Somewhere in your control panel you should have a cron jobs tool.

With the cron jobs tool you set the file you want it to run and how often you want to run it.
 
1
•••
:-/
I do have cPanel X though.
 
0
•••
1
•••
'Cept your shell script probably won't be called "/home/users/websites/urch.sh". Hostgator uses /home/your-account-name as your home directory and if you've saved urch.sh in a subdirectory you'll have to account for that too, so you'd have to change /home/users/websites/urch.sh to /home/your-account-name/path-to-file-if-applicable/urch.sh

Also, make sure you change permissions on urch.sh to make it executable (you can do that through the Cpanel file manager) or cron won't be able to run it! And, you'll need write permission on the directory where the .js file is being written. Your cron entries should run under your user ID so setting these permissions for "user" only should work.

The command shown will suppress error output. If things don't seem to be working and you need to debug, log the output to a file somewhere in your account by changing /dev/null to /home/your-account-name/some-writeable-directory/foo.log. Then after the job runs, all error and standard output will be in foo.log.

Does that make any sense?
 
Last edited:
0
•••
Thanks! That's the latter part that cleared up a bit.
But what do i need to do to create a shell script?

Do i need to save the code into a Notepad file and call it urch.sh ??
You know just like a .htaccess file?

Also what i don't understand by reading the partial URL in the tutorial is why it needs to be uploaded so deeply?

11 12 * * * /home/user/websites/urch.sh >/dev/null 2>&1

It's three folders deep?

Is there a special reason for this? or could it also be done by doing it like this:

11 12 * * * /public_html/analytics/urch.sh >/dev/null 2>&1

To recap:
So i can create a folder like this: /public_html/analytics/urchin.js

^That is where i drop Google's code

Then create a folder like this: /public_html/analytics/urch.sh

Add this to my crontab:

/public_html/analytics/urch.sh >/dev/null 2>&1

But why is the first part of the line being left out? --> 11 12 * * *
(See screenshot 2) This should be added right?

And then drop this code at the bottom of my page code?:

<script src="/z/j/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-000000-x";urchinTracker();
</script>


And that's it?

Edit:
Thanks for the reply Enlytend!
The only thing I'm confused about know is to add the 11 12 * * * part in the beginning? Because i didn't see that in the screenshot.

I presume it should so I'll give that a try and let you guys know how it works out :)
 
Last edited:
0
•••
But why is the first part of the line being left out? --> 11 12 * * *
(See screenshot 2) This should be added right?

Nope - that's added for you through the Cpanel interface when you specify the date and time.

What that part means is to run your job 11 minutes after 12, on every day of every month and any day of the week.

You can put your file in /public_html/analytics, but you need to preface it with /home/your-user-account because you need to give it the entire path to the script on the (in this case, shared) server. So it would be /home/your-account/public_html/analytics/urch.sh.

(unless Cpanel appends your home directory pathname to the command, but I'm pretty sure it doesn't).
 
1
•••
Thanks for clearing that up!
I really appreciate your input guys :tu:

I'll let you guys know how it turns out.
 
0
•••
What he shell script is doing is downloading the latest version of urch.js. This could be done via a php file and then ran via a cron job every so often too.

To do this you will need something like the code below in the php file. Then set a cron job to run that file every so often. Make sure the folder where you save the urch.js file has write permissions.

PHP:
// init
      $urch = "http://www.google-analytics.com/urchin.js";
      $filename = ""; // enter where you are saving the file eg ("urch/urch.js")

// get contents of the file
      $filecontent = file_get_contents($urch);

// Open or create file
      if (!$handle = fopen($filename, 'w')) {
           exit;
      }
      // Write to opened file.
      if (fwrite($handle, $filecontent) === FALSE) {
          exit;
      } 
      fclose($handle);
 
Last edited:
0
•••
Truehost โ€” .com domains from $4.99, hosting includedTruehost โ€” .com domains from $4.99, hosting included
Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back