Gossamer Forum
Home : General : Perl Programming :

Limit access to a file depends on date

Quote Reply
Limit access to a file depends on date
Hi! I was wondering if anyone could recommend a script that can achieve the following purpose:

I have articles that would be published every month. I would like to be able to upload it up into my server prior to the publication date and users can't access it until that date has arrived.

Thanks.
Julian
Quote Reply
Re: [vampy] Limit access to a file depends on date In reply to
Hello Vampy,

Just an partial idea , not a written solution :

Use crontab . [ linux ? ]

Since crontab can be set to run just after midnight [server time] , you can run a program

to test for the date and then copy the file with a new name to a web folder and

update/create a link in a html index page so people know it is there.

-the reason I mentioned [server time] is time zones may be an issue if you serve

the whole world relative to where your server is.

More information may be required to write a solution.


Hope this helps

kode

Last edited by:

kode: Oct 26, 2002, 8:13 AM
Quote Reply
Re: [kode] Limit access to a file depends on date In reply to
Thanks for your reply. I thought about that as well. I'm not very sure how to write a crontab though as I never wrote one before.

What I thought was like what you said to upload the file to a folder that users can view and then when the time comes, crontab would move the file to the readable folder.

I suppose then I will also have to run a cgi script to update the page where the link to the new article is again using crontab?

Thanks.
Julian
Quote Reply
Re: [vampy] Limit access to a file depends on date In reply to
Hello Julian,

crontab 101 very brief :

The crontab daemon loads an ascii text file with commands based on user and runs these commands.

crontab mycrontab.txt <enter> loads mycrontab.txt into crontab

Edit mycrontab and reload as above is the easy way to make changes, each load overwrites the previous cron job.

Assuming you are at a linux command prompt type: crontab -l <enter> [ that's a small L not an i ]

This will list your crontab jobs, if any. And you will find out if you are in the /etc/cron.allow file or the /etc/cron.deny.

man crontab -> will explain the mighty Cron , god of repetative tasks.

crontab -h -> Help

Search google for crontab should give you many guides to creating the ascii text file.

One thing to note , crontab creates mail for the user it runs under, filling up a mail box until read/deleted.

You can turn off mail with MAILTO='' [ 2 single quotes] or MAILTO=/dev/null at the top of the text file.

Always use full paths in a crontab text file or $HOME things :

# Send mail to no one

MAILTO=''

# run five minutes after midnight, every day
5 0 * * * /usr/bin/perl /home/bob/test.pl




See the many examples you will find on the web for details on the syntax for timing.

Hope this helps

kode