Jump to content

Schedule Task to Execute URL


Recommended Posts

By firing off a URL I mean connect to a web page on the Internet that may run some code.

 

Basically my shared web hosting charges a lot for scheduled tasks so I thought I could run these from unraid.

 

Thanks for explaining. I figured it would be some form of wget. I just didn't get why a web page. BRiT saw it right away.

Link to comment

Cron is the scheduler in linux. There are a few examples in the forum.  Depending on how often you want to run will determine the exact command.  Here is a example of a weekly backup set up in cron. http://lime-technology.com/forum/index.php?topic=18238.msg163989#msg163989

 

Wget provides a means to dlownload files from the web or to be more accurate...GNU Wget 1.11.1, a non-interactive network retriever. I got that right from the app.

 

Get a telnet window going on your server and type "wget --help" to see all the options.

 

I'm not sure where AT is getting used but its a command line scheduler. Look up AT and ATRM..they go hand in hand.

 

I would start with wget, script the job you want to run. Once you have that you'll just have to add it to the go file so it gets imported to cron on reboots. Trust me it sounds harder than it is. Give it a crack and post when you get stuck.

 

 

had a DUH moment...At would be used instead of cron.  :-[ 

Link to comment

Ok, I think I have most of it figured out.  There was another post that basically did the same thing.

 


#!/bin/bash

# Extract root's crontable. 
crontab -u root -l | grep -q "/boot/scripts/scheduler.sh" > /tmp/crontab.tmp

grep -q "/boot/scripts/scheduler.sh" /tmp/crontab.tmp 1>/dev/null 2>&1
if [ "$?" = "1" ]
then

# Append new entries to root's crontable
cat <<-EOF >> /tmp/crontab.tmp
# Schedule wget :
#59 * * * * /boot/scripts/scheduler.sh >/dev/null 2>&1
EOF

# Update root's crontable.
crontab /tmp/crontab.tmp -u root

# If we don't copy the new crontab to "root-", the additions will be deleted
# if you use the management interface to make any changes.
cp /tmp/crontab.tmp /var/spool/cron/crontabs/root-

fi

rm /tmp/crontab.tmp

 

So then in scheduler.sh, I have a bunch of wget to the websites I want to fire off at the 59th minute of every hour (just an example).

 

So to get this to stay active on a reboot, could I just add "/boot/scripts/cron_web_scheduler.sh" in the GO file?

 

Is there a quick way to see what cron jobs are active, and a way to easily remove jobs?

Link to comment

Your well on your way..

 

add to go file to run on reboot. Make sure the script is executable.

 

ls -l inside the scripts folder to verify this.

 

If we deconstruct the start of the script you posted you can see how to list crontab for root.

crontab -u root -l

 

type crontab from shell and you'll get this.

 

crontab 2.3.3

crontab file <opts>  replace crontab from file

crontab -    <opts>  replace crontab from stdin

crontab -u user      specify user

crontab -l [user]    list crontab for user

crontab -e [user]    edit crontab for user

crontab -d [user]    delete crontab for user

crontab -c dir      specify crontab directory

 

 

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...