tags:

views:

31

answers:

3

how can i call some url like stackoverflow.com from cron without getting return data from page?

+1  A: 

use this:

wget --spider http://www.stackoverflow.com > /dev/null 2>&1

This command calls the url but doesnt download the output and redirect stderr and stdout to /dev/null

Numenor
A: 

if your just want to make request using wget

wget http://stackoverflow.com      

here is your script to open a url like google.com in firefox and to keep it in cron check this

OR

if you want to open page in FF optionally then go for this script

#!/bin/bash
# 
# This scripts opens the urls in existing instance of firefox
# it uses a new-tab without showing annoing alert about used profile 
# 
# Name: mozilla-firefox
# Requirements: firefox, bash, pwd, grep ;-)
#
# Daniel Kmiec 
# 19.05.2004
#

#if no parameter is given det the default url 
if [ -z $@ ]; then
default_url="http://www.google.com"
else
   default_url=$@
fi
# check if we want to open url or a file
# if the specified file exists we use openfile
if [ -f $default_url ]; then 
   pwd=`pwd`
   dir=`dirname $default_url`
   is_not_relativ=`echo $dir | grep -E "^/"`

   if [ -z $is_not_relativ ]; then #is relativ
      default_url=$pwd/$default_url
      echo $default_url
   fi
((firefox -remote "openfile ($default_url, new-tab)" || firefox $default_url) >/dev/null) &
else
   ((firefox -remote "openurl ($default_url, new-tab)" || firefox $default_url) >/dev/null) &
fi   
org.life.java
+1  A: 

The format for cron is as follows:

# Minute   Hour   Day of Month       Month          Day of Week        Command    
# (0-59)  (0-23)     (1-31)    (1-12 or Jan-Dec)  (0-6 or Sun-Sat)                

For example, a cron to run at 9am every day and connect to a site would look like this:

0 9 * * * wget --spider http://www.stackoverflow.com > /dev/null 2>&1

Run crontab -e to edit the crontab, add this line to it and save.

dogbane