LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Crontab script (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-script-4175453826/)

ikn3 03-12-2013 04:52 PM

Crontab script
 
Schedule a script "removelogs" in a CRON job. We have to make this a script and run with the full path

Also please make sure to source the environment before running this.

Not sure what sourcing means and how to achieve it.
TO run the script manually it needs to be run as
". ./removelogs" from its directory.

Adding the ERROR from mailer spool
../pkms.env is missing. Please run cron_removelogs from the scripts dir

Where cron_removelogs = FIle which invokes the script:
cat cron_removelogs
#!/bin/sh

. /home/admin/.bash_profile

# Source the Environment
redit

# Run the removelogscores script
. /<path to actual script>/removelogs


And the path for alias "redit" is mentinoed in /home/admin/.bash_profile

chrism01 03-12-2013 07:59 PM

1. show us what you've got so far
2. use code tags https://www.linuxquestions.org/quest...do=bbcode#code
3. sourceing means pulling code into the current env either by using
Code:

# this is <dot><space>somefile as per your
# ". ./removelogs"

. somefile

# or use source cmd
source somefile

You will need to supply a path prefix to somefile so the dot or source cmd can find it.

Useful links you should read
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
http://www.adminschoice.com/crontab-quick-reference

shivaa 03-12-2013 10:22 PM

In simple words, sourcing means to load or set what is mentioned in specified file line-by-line. So,
Code:

. /<path to actual script>/removelogs
... means that read the file removelogs line-by-line and load or set everything mentioned in it, in your working shell environment.

Similarly,
Code:

. /home/admin/.bash_profile
... means that read the file .bash_profile line-by-line and load or set everything mentioned in it, in your working shell environment.

I suppose, your script (which has to be scheduled in cron) is cron_removelogs, not removelogs file.

Anyway, let's know what problem you're facing?


All times are GMT -5. The time now is 11:07 PM.