Auto-Ping Search Engines to Re-Crawl Your Sitemap
Search engines discover new and updated pages faster when you actively notify them that your sitemap has changed. Both Google and Bing expose a public ping endpoint that accepts a sitemap URL and queues a fresh crawl request. Automating this on a schedule ensures your content is indexed promptly without any manual work in Search Console.
Schedule
0 6 * * 1Every Monday at 6:00 AM
Setup
- 1
Locate your sitemap URL
Confirm your sitemap is publicly accessible. It is typically at https://yourdomain.com/sitemap.xml or listed in your robots.txt under the Sitemap: directive. Open the URL in a browser to verify it returns valid XML before proceeding.
- 2
Create a heartbeat monitor in CronJobPro
In your CronJobPro dashboard, create a new Heartbeat monitor with a period of 7 days and a grace period of 12 hours to match the weekly schedule. Copy the unique ping URL you receive, which will look like https://cronjobpro.com/ping/<token>. You will embed this URL in the script.
- 3
Deploy the ping script to your server
Save the script below to your server, for example at /usr/local/bin/ping-sitemaps.sh. Replace SITEMAP_URL and HEARTBEAT_URL with your actual values. Make it executable with: chmod +x /usr/local/bin/ping-sitemaps.sh
- 4
Register the cron job
Open your crontab with crontab -e and add the schedule line shown below. This runs the script every Monday at 6 AM in the server timezone. Ensure the server timezone matches your expectations by checking with timedatectl or date.
- 5
Verify the first run
After the first scheduled execution, check the CronJobPro heartbeat monitor dashboard to confirm the ping arrived. Also inspect /tmp/ping-sitemaps.log on your server for the HTTP response codes from Google and Bing, which should be 200 or 202 for a successful submission.
The script
bash
#!/usr/bin/env bash
# ping-sitemaps.sh
# Notifies Google and Bing that your sitemap should be re-crawled.
# Dependencies: curl (pre-installed on most Linux systems)
set -euo pipefail
SITEMAP_URL="https://yourdomain.com/sitemap.xml"
HEARTBEAT_URL="https://cronjobpro.com/ping/YOUR_TOKEN_HERE"
LOG_FILE="/tmp/ping-sitemaps.log"
log() {
echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] $*" | tee -a "$LOG_FILE"
}
ping_engine() {
local name="$1"
local endpoint="$2"
local full_url="${endpoint}$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1],safe=''))"
"$SITEMAP_URL")"
local http_code
http_code=$(curl --silent --output /dev/null --write-out "%{http_code}" \
--max-time 30 "$full_url")
log "$name ping returned HTTP $http_code"
if [[ "$http_code" != "2"* ]]; then
log "WARNING: $name returned non-2xx status $http_code"
return 1
fi
}
main() {
log "Starting sitemap ping for: $SITEMAP_URL"
# Google: public ping endpoint (no authentication required)
ping_engine "Google" "https://www.google.com/ping?sitemap="
# Bing (also covers Yahoo, DuckDuckGo via Bing index)
ping_engine "Bing" "https://www.bing.com/ping?sitemap="
log "All pings completed successfully."
# Signal success to CronJobPro heartbeat monitor
curl --silent --output /dev/null --max-time 10 "$HEARTBEAT_URL"
log "Heartbeat pinged: $HEARTBEAT_URL"
}
main
Monitor it
Create a Heartbeat monitor in CronJobPro with a period of 7 days and a grace period of 12 hours. The script calls your unique ping URL at https://cronjobpro.com/ping/YOUR_TOKEN only after all sitemap pings succeed. If the script crashes, times out, or a search engine returns an error, the heartbeat ping is never sent. CronJobPro will alert you once the grace window expires, meaning you know not just that cron fired but that the entire job ran to a successful conclusion. For failed runs you can also call https://cronjobpro.com/ping/YOUR_TOKEN/fail explicitly in a trap handler if you want immediate failure alerts rather than waiting for the grace period. Alerts can be routed to email, Slack, Discord, Teams, PagerDuty, Opsgenie, or any webhook endpoint you configure in the monitor settings.
Frequently asked questions
Does pinging Google actually speed up crawling?
The Google ping endpoint queues a crawl request, but Google makes no guarantee about how quickly it will crawl or index the content. It is most useful after publishing a batch of new or updated pages. For large or authoritative sites the difference is often small; for newer or lower-traffic sites it can meaningfully reduce lag.
Is the Google sitemap ping endpoint going away?
Google deprecated the dedicated ping endpoint in 2023 for sites not already using it, recommending Search Console API submissions instead. However, the endpoint still functions for existing users. If you manage a high-traffic site or want a more reliable signal, consider authenticating with the Search Console API and using the sitemaps.submit method instead, which requires a service account.
Why ping weekly instead of every time content changes?
Search engines rate-limit and may ignore excessive pings. A weekly schedule is a reasonable default for most publishing cadences. If your site publishes many articles daily, consider triggering the ping from your deployment or CMS publish hook instead of a fixed schedule, so pings correlate with actual content changes.
What should I do if the script reports HTTP 429 or 503 from a search engine?
A 429 means you are pinging too frequently; reduce the schedule frequency or switch to event-driven pings tied to content publication. A 503 means the ping endpoint is temporarily unavailable; the job will succeed on the next run. In both cases the heartbeat ping in the script is skipped, so CronJobPro will alert you, giving you visibility into these transient failures.