Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I do not have previlage to use crontab -e to run my script. Is there other way to periodically run my script? Basically I need to run it once a week.

share|improve this question
add comment

4 Answers

If enabled and installed, you can use the at command. However it is a one time only scheduling....you'd have to run a new at command within the thing that you wanted rescheduling.

Check out the man pages for help on the at command.

But remember, it is not always installed/enabled on all Linux/UNIX systems.

share|improve this answer
    
And somebody who doesn’t have the privilege to use cron might not be able to run at, either. –  Scott Feb 9 '13 at 21:43
    
True, in general, cron and at are administered via two different access lists. –  mdpc Feb 9 '13 at 21:44
add comment

The REAL answer to this is to contact your friendly neighborhood systems administrator, explain your problem, and ask them to enable cron access for you. You should explain how your program runs, its resource requirements, and generally make a promise that you will not harm the system if you get cron access privs.

share|improve this answer
    
shouldn't you be posting both of these as one answer? –  Journeyman Geek Feb 10 '13 at 10:04
    
I figured they were two completely different answers. –  mdpc Feb 11 '13 at 0:35
    
Even if they were, its accepted practice to post them together. "You can do X, or alternatively Y" rather than posting two answers. –  Journeyman Geek Feb 11 '13 at 0:49
add comment

If you can't/don't want to keep a terminal open, you could run it in GNU Screen/tmux or with nohup.

Examples:

screen sh -c 'while sleep 7d; do mycommand; done'

or

tmux 'while sleep 7d; do mycommand; done'

Note: these commands will run mycommand the first time after a week and then periodically, not directly. Change according to preference.

See the projects' documentation for more info on attaching/detaching sessions.

(7d is GNU specific, I believe. Just put 604800 there instead if the sleep version only supports seconds.)

share|improve this answer
    
As a systems administrator, I really hate seeing these type of things. They take up job slots, and are not very reliable, if the machine gets booted, then the job of course stops and thus you have a problem. –  mdpc Feb 9 '13 at 21:41
add comment

Another approach would be to have a cronjob running on a different machine, that uses ssh to execute a certain command on the target server. If you set up key based login, this will be easy.

Just set up a cronjob on another machine that looks like e.g.

0 0 * * 7   /usr/bin/ssh remoteuser@remotehost mycommand

With the exception of the remote server being offline at the execution time, this would be reliable over remote server restarts and other things.

share|improve this answer
    
I'm sure an admin would be happy about this one. –  mdpc Feb 11 '13 at 0:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.