by ComputerBob
November 21, 2006
This article is about troubleshooting a technical problem. Even if you don't use the sitemap generator script that it describes, this article contains some valuable lessons about how to follow logical steps to solve a problem, even if that problem is beyond your technical expertise.
As I described in my article, The Best Sitemap Generators, I bought and have been using XML-Sitemaps' sitemap generator script to create this site's sitemaps. It did a great job each time I ran it manually, but I got error messages every time I tried to get it to automatically run as a scheduled cron job on my web server.
If you're not an XML-Sitemaps' script user, you probably don't care much about that, but once the search engines index this article, I bet it will get a lot of visits from XML-Sitemaps' customers who are having the exact same problem. The good news is that I stayed up until after 3:00 in the morning this past Sunday night, and figured out how to make the XML-Sitemaps' sitemap generator script run as a cron job. There, that last sentence should help other XML-Sitemaps' customers find this article in the search engines.
Here's what was going wrong before I finally solved the problem. By following the XML-Sitemaps installation instructions, I went into the crontab section of my web site's HSphere control panel and set up the cron job. In the crontab's "Command" box, I entered the exact, really long path (address) of the sitemap generator script that the sitemap generator script itself had told me to put in that box. Then I told the new cron job to run the following minute. Then I waited. After one minute had gone by, I checked my email, and there was a message from the crontab interface, telling me that it couldn't run my cron job because it couldn't find the sitemap generator script. So, I carefully checked the script's path that I had put in the "Command" box and ran the cron job again. A couple of minutes later, I got another email message, telling me that the script couldn't be found. So, I tried removing the very first folder name from the path in the "Command" box, and running the cron job again. I got another email, telling me that the script could not be found. Then, I tried removing the second folder from the path. Same result. Third folder. Same result. When I had finally shortened the path to just a few folders, I got an email with two different error messages — the first one said that it couldn't run the sitemap script because "permission denied." The second one said that there was an error in the script itself — something about a missing ")" sign. That make me think that my web server had at least found the sitemap script, but it was having trouble running it. So I tried changing the script's permissions on my web server, hoping to find the right combination of permissions to allow it to run. No matter what permissions I gave it, it still refused to run, and I still kept getting emails with the same two error messages.
That whole trial-and-error process continued until I had tried every possible combination of paths and permissions, but I still couldn't get my cron job to run. That's when I finally decided to explore the possibility that the path that the script had told me to put into the crontab's "Command" box might be wrong.
I searched the XML-Sitemaps' support forums, and found several people who had reported the same problems in the past, but I didn't find anyone offering them any real solutions to the problem, other than to make sure that they were typing the path to the script correctly in the crontab's "Command" box.
So I searched the web, looking for clues that would tell me the correct path to run a PHP script as a cron job. My searches convinced me that the HSphere control panel that my web host uses probably does require a different path in its crontab "Command" box than the cPanel control panel that most web hosts use. But what is that HSphere path supposed to be? I couldn't find anything that would tell me.
Finally, while following a link from a link from a link, I discovered the correct HSphere path in a post that someone had mentioned in a long-lost forum over a year ago. It was almost exactly the same as the path that I had been using. That means that the path that the script had told me to use, the path that I had been trying to get to work for the past several hours, had been almost right. But, as anyone who has ever programmed a computer can tell you, computers don't work when things are almost right — computers require things to be exactly right. To a computer, almost right is the same thing as totally wrong. It's like when you call a friend on the telephone: you won't reach them if the number that you dial is almost right — it has to be exactly right.
So, for all of you XML-Sitemaps customers who are using the HSphere control panel and can't get the sitemap script to run as a cron job, the solution is to change the path that the script tells you to use, so that it will work with your HSphere control panel.
The XML-Sitemaps' sitemap generator script tells you to put the following path in the crontab's "Command" box:
/usr/bin/php /hsphere/ (etc., etc., etc.)
Yes, there's one space between /php and /hsphere. It's supposed to be there. Don't remove it.
That path is the right path for people who use the cPanel control panel, but it is wrong for people like me who use the HSphere control panel.
If you use the HSphere control, you need to put the following path in the crontab's "Command" box:
/usr/local/bin/php /hsphere/ (etc., etc., etc.)
In other words, you have to add /local in between /usr and /bin.
Yes, there's one space between /php and /hsphere. It's supposed to be there. Don't remove it.
When I put that correct path in the crontab's "Command" box, my cron job ran the very next minute. It only took about 25 seconds for it to create a new sitemap of this site, and I finally went to bed and got some sleep. From now on, that cron job will run at 1:50 every morning, automatically generate a new sitemap of my site, and then automatically notify Google about it.![]()