LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Crontab file located in,,, where? (https://www.linuxquestions.org/questions/linux-software-2/crontab-file-located-in-where-200946/)

jon_k 07-04-2004 05:26 AM

Crontab file located in,,, where?
 
Okay, I got a pretty big problem here, I'm not sure what to do exactly.

I kept trying, trying, restarting from scratch and everything until I was actually yelling and cussing and pulling my hair out. I'm not sure what to do, and hopefully one of you have had a similiar expierience and will be able to share your insight

First off, I don't like crontab -e , actually, not to offend anyone but I hate it. Isn't there a way to edit your own crontab with the editor of your choice?

I am use to editing my crontab file in root on my linux machine at home here using the command nano /etc/crontab

Unfortunately, since I don't have root to this box I'm on... (professionally hosted) I can't do that.

Is there any file where I could edit crontab using the editor of my choice, like... /home/jon/.crontab or something? -- This server is running on Redhat Linux 7.2 by the way, in case the file path may vary from distro to distro.


Now, let me present my problem that made me ask this question to see if you could if anything, help me with this.

You see, I'm not able to get a script to run, I've been adding it to webmin to execute at a certain time... then typeing date like a mad man in SSH waiting for it to go off...... it's time to execute goes by... and nothing ever seems to have happened. Spent 2 hours making the cronjob in webmin trying to get it to work to no avail.

(Actually, I have gotton it to run once or twice... and then when I double-checked to see if it'd work within the next 5 minutes (to make sure I got it working and just not a 1 time thing... it didn't do a darn thing!!!... I'd then create a new cron entry and start over.....)

Thats why I want to add the cron manually, but without crontab -e

Here is a screenshot of the settings for crontab I have... you know.. the settings that don't execute when it's time to execute comes?

http://www.picrack.com/002/avatars/crontab1.JPG



I counted down for it to hit 5:00AM in the ssh console, typing "date" like I was crazy, and 5:00AM went by... 5:01,,, 5:02... 5:03... nothing ever happened, I didn't get "New mail" neither explaining any errors

Any ideas on how I would be able to get this to work... or add the crontab manually WITHOUT using crontab -e?


A tack of the code I'm trying to execute, not that it probably matters though since it runs fine if I ./ it from ssh

Code:

#!/bin/bash

# A script that will back up pserver files by date and time.
# Here's how it works...
#1) Define your variables man!
#
#2) Create a tempdir e.g. July,07-03-2004-09:41:22AM.tempid=1088872882
#  Basically, this creates a temporary dir with all the files in it
#  it is given a temorary ID basted on amount of seconds since jan 1 1970
#
#  I would have used %N which is nano seconds, but the server I coded this
#  for apparently has an older version of date which doesn't support that sequence
#
#3) cp (copy) all the files youw want to back up to the new tempdir, simple enough, heh
#
#4) tarballz the items in the temp directory we made and copied stuff too
#
#5) delete the temp directory and its contents



instance=${1:-palace}
root=${2:-/home/jon/pserver}
temptime=${3:-`date +%B,%m-%d-%Y-%I-%M-%S%p.tempid=%s`}

#script written by Jon Kelley <jonkelley@gmail.com>
#I don't care if you use it or rip it apart or use it in a
#commercial product, just give me credit for it

/home/jon/pserver/bin/stop-palace
# ^^^ Stop server!

mkdir $root/$instance/psdata/backup/$temptime/

cp $root/$instance/psdata/pserver.pat $root/$instance/psdata/backup/$temptime/pserver.pat
cp $root/$instance/psdata/pserver.prp $root/$instance/psdata/backup/$temptime/pserver.prp
cp $root/$instance/psdata/pserver.prefs $root/$instance/psdata/backup/$temptime/pserver.prefs
cp $root/$instance/psdata/pserver.conf $root/$instance/psdata/backup/$temptime/pserver.conf
cp -rf $root/$instance/psdata/plug-conf $root/$instance/psdata/backup/$temptime/plug-conf

tar -cvzf $root/$instance/psdata/backup/`date +%B-%m-%d-%Y--%I-%M-%p`.backup.tgz $root/$instance/psdata/backup/$temptime/

/home/jon/pserver/bin/start-palace
# ^^^ Start the server back up!

rm -rf $root/$instance/psdata/backup/$temptime


JohnLen 07-04-2004 07:30 AM

If you don't like the default editor (probably it's vi on your system), you can set your own editor, by pointing at it's location using VISUAL environment variable.

jon_k 07-04-2004 10:35 AM

What would I do for that?

export $visual = /usr/bin/nano ??

Thanks

wipe 07-04-2004 01:24 PM

There are many ways to set environment variables, the usual one being:

name=value

When a program executes, it gets its own environment. You can make it inherit variables from the shell the program is executed in. For example:

name=value
export name
program

When you use export name[=value], you don't usually put $ in front of the variable name, otherwise the name is replaced by the variable's content before the command is executed and you end up exporting a different variable.

Put this in your ~/.bash_profile:

export VISUAL=/usr/bin/nano

The "profile" file is executed when the login shell starts, that is to say, when the system boots. The variable VISUAL is then copied to every shell that gets started and is (nearly) always visible.

If you want to know where cron finds its files, I strongly suggest you to read some documentation. "man cron" and "man 1 crontab" give the basics. There also seems to be alternatives to cron. I base this assumption on a quick sf.net search.

Regards
Simon

jon_k 07-04-2004 01:26 PM

Wow thanks, was hunting for an answer when I heard the "new mail" notification sound, "Linux Questions Mailer: reply to ccrontab...."

thanks for the answer again!! I'll try it ! ;)

[edit]Worked, thank you so much!


All times are GMT -5. The time now is 04:04 AM.