LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General > LinuxQuestions.org Member Intro
User Name
Password
LinuxQuestions.org Member Intro New to LinuxQuestions.org? Been a long time member but never made a post? Introduce yourself here.

Notices

Reply
 
Search this Thread
Old 04-28-2004, 11:21 AM   #1
JolynnMarie
LQ Newbie
 
Registered: Apr 2004
Posts: 1

Rep: Reputation: 0
shell script fo run auto job in cron


I need to write a shell script that asks a user to input a single-line command that they want to have executed once a week. Ask the user to input the day of the week on which they want the command to be executed. I have submit their command as a correctly formatted cron job. Will this work?
#!/usr/bin/perl -w
use strict:
print "enter commnad to be run: ";
chomp (my $ command = <STDIN>
print "Enter the day of the week to run: ";
chomp (my $day = <STDIN>);
$day =~ tr/A-Z/a-z/;
unless ($day =~ /^(m|tu|w|th|f|sa|su)/) {
print "Error: You did not enter a valid week day\n";
exit 0:
}
if ($day =~/^m. *$/) {
$day = "mo";
}
if ($day =~ /^tu. *$/) {
$day = "tu";
}
if ($day =~ /^w. *$/) {
$day = "we";
}
if ($day =~ /^th.*$/) {
$day = "th";
}
if ($day =~ /^f.*$/) {
$day = "f";
}
if ($day =~ /^sa.*$/) {
$day = "sa";
}
if ($day =~ /^su.*$/) {
$day = "su";
}
my %week = ("su","0","m","1","tu","2","we","3","th","4","fr","5","sa","6");
open my $fh, ">/tmp/ctab" or die "$!";
print $fh "0*** $week{$day} $commnad \> \/dev\/null 2\>\$1\n";
close $fh;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
run shell script on cron varunbihani Linux - Newbie 5 07-08-2005 01:50 AM
How to write a script to run bitdefender antivirus as a cron job? ginda Linux - Software 1 03-10-2005 08:08 PM
how to run this cron job ashley75 Linux - General 5 05-24-2004 11:20 AM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM
Cron job does not run brentos Linux - General 6 12-12-2003 02:37 PM


All times are GMT -5. The time now is 10:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration