# Wget Question

## JasonX

I use wget at my home network server to download files at night while internet connection is not used.

In my crontab is written:

```
/usr/bin/wget -c --directory-prefix=/incoming/files --input-file=/incoming/downloads -o /incoming/wget.log
```

I add links to download in file /incoming/downloads. Links in my /incoming/downloads file is not erased when file download is done. And i need to delete it by myself that is not acceptable. The Question is:

What i need to do(what script or any other solution) that completed links were deleted from /incoming/downloads file right after download?

Thanks for attention

----------

## slackline

 *JasonX wrote:*   

> I use wget at my home network server to download files at night while internet connection is not used.
> 
> In my crontab is written:
> 
> ```
> ...

 

Could you not change your crontab entry to something like...

```
/usr/bin/wget -c --directory-prefix=/incoming/files --input-file=/incoming/downloads -o /incoming/wget.log && rm /incoming/downloads/*
```

Using '&&' means that the first command is completed before the second is started.

----------

## JasonX

Thanks for the help. There is some misunderstanding.

 *Quote:*   

> 
> 
> ```
> /usr/bin/wget -c --directory-prefix=/incoming/files --input-file=/incoming/downloads -o /incoming/wget.log && rm /incoming/downloads/*
> ```
> ...

 

/incoming/downloads is a regular file... How can this entry delete strings of regular file?

```
rm /incoming/downloads/*
```

My crontab entry for wget automation is:

```
0 3 * * * /usr/bin/wget -c --directory-prefix=/home/p2p/mldonkey/incoming/files --input-file=/incoming/downloads -o /incoming/wget.log

0 9 * * * /usr/bin/killall wget
```

But what if a file download will not be finished completely and wget will be killed? And before next execution of wget the new strings will be added?

I need per line deleting entries of a /incoming/downloads file after wget complete download of this file. How can I realise that?

----------

## Zhaozhou

Check --delete-after.

----------

## JasonX

 *Zhaozhou wrote:*   

> Check --delete-after.

 

This will delete downloaded files on local machine after upload.

This won't help me ... 

Thanks for reply

----------

## halfasleep

Yo,

Does something like this help?

```
for file in $(cat /incoming/downloads); do

        echo $file;

        usr/bin/wget -c --directory-prefix=/incoming/files -o /incoming/wget.log $file

        cat /incoming/downloads | tail -n $((`cat /incoming/downloads | wc -l` -1)) > list

done

```

Check it, should remove the first line in the file after wget ends (you might wanna look at checking the exit status, and doing some other action if it fails)

----------

## halfasleep

Oh, just thought I should add:

Probs best to kill the script in the morning or it'll just rerun wget

L8r

----------

