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.

How would i write a simple cron job to email myself a message at a certain time? Also is it possible to create a cron job without root access. I'm trying to use my school's server?

share|improve this question

migrated from stackoverflow.com Feb 19 '12 at 12:53

This question came from our site for professional and enthusiast programmers.

    
issue "crontab -e" to check if you even have the ability to schedule a cron task. You can look for the /etc/cron.* directories, but I doubt they are open for you to add anything. –  tawman Feb 19 '12 at 7:09

2 Answers 2

Check if your name appears in the file /etc/cron.allow

If your name is not listed in /etc/cron.allow, you can use crontab if not listed in /etc/cron.deny. If neither file exists, unfortunately only the root user can use crontab.

You can put a job in crotab with crontab -e option following the pattern bellow.

*     *     *   *    *        /path/to/script.sh
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

Create a simple like the sample bellow to send you the mail:

#!/bin/sh
 EMAILID="your@email"
 MAIL=/tmp/mail.$$
 echo "Line 1">$MAIL
 echo "Line 2" >>$MAIL
 echo "Line 3" >>$MAIL
 ...
 mail  -s "Subject" "$EMAILID" <$MAIL
 rm -f $MAIL
share|improve this answer

Any cheapest hosted solution will give you a cron job manager, even if you do not have a root access.

If not a cron, you can always do a simple script that wakes after certain time, and email you

for(;;){
  email();
  sleep(60);
}
share|improve this answer

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.