Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-27-2005, 07:11 PM   #1
LQ Newbie
Registered: Aug 2005
Posts: 2

Rep: Reputation: 0
cron command

hi there....not just a new newbie...but a total newbie

i am trying to set a cron job on my web server, i know the format is in unix style

i have an ftp account that i want my webserver to access and then once accessed to simply delete a specific file

i know how to get the cron to contact the remote machine..i think

lets say the username is mike and the password is mike for the remote ftp account

some thing like this isnt it?

the file i want to delete is located in the root of the ftp account.

i know the command for deleting a remote file is simply "delete". but i do not know who to structure the command. Any help would be appreciated
Old 08-27-2005, 09:39 PM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 245Reputation: 245Reputation: 245
If you have ssh enabled, your probably better off creating a quick script to remove the file by using ssh keys so you don't have to pass a password to the server.

Create the script:

# Script to remove a file from remote server.

for machine in <hostname-here>
   ssh -i $machine /bin/rm /path/to/file
Make the script executable by doing: chmod +x <scriptname>

Then just add this to your crontab (the example would run at 2:20 AM daily):

20 2 * * * /path/to/script/created/above 1> /dev/null
man ssh to read more about how to setup ssh keys so it doesn't prompt for a password.

Last edited by trickykid; 08-27-2005 at 09:40 PM.
Old 08-28-2005, 12:04 AM   #3
Registered: Jun 2005
Posts: 96

Rep: Reputation: 15
Re: cron command

this should take care of it for you...
(NOTE: i am using your example so change it accordingly )

create ~/.netrc and change its permissions to rw only by you chmod 600 ~/.netrc if it does not already exist, otherwise just add the following anywhere in the file as long as it is above any 'default' line you have

in .netrc place this line
machine 2##.1##.82.1## login mike password mike
this should allow for auto-login. you can confirm this by running 'ftp 2##.1##.82.1##' if it logs you in without prompt for user/pass then continue

example script (script_name):
# used to delete filename_to_delete from 2##.1##.82.1##
ftp << EOF
open 2##.1##.82.1##
delete filename_to_delete
that should be it. make the script executable (chmod 700 script_name), then add it to cron.
confirm that it works from cli first. if it works when invoked from cli (./script_name) but not from cron then add . /etc/bashrc above the 'ftp << EOF' line and try again

hope this helps

[EDIT: i would agree with trickykid on using ssh if possible]

Last edited by mhallbiai; 08-28-2005 at 12:06 AM.


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
works on command not on cron rickict Linux - General 1 11-17-2005 02:52 PM
Cron, unknown command Buto Linux - Software 1 09-07-2005 01:09 PM
How to run my cron command ? Tanc Linux - Newbie 6 05-28-2005 04:58 PM
Help with a cron command phatboyz Linux - Software 2 01-19-2005 11:09 AM
How to use cron command in solaris meng_en General 1 11-06-2002 09:08 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:20 PM.

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