Slackware Cronjob
I am new to slackware I am trying to execute a cronjob while I have a script but even beeing a root i am not able to add in cronjob I cant edit it.
using current slackware on rasberi pi ( I am yet in learning phase I have been on linux like more then a year but still learning ) |
Is dcron installed on your system ?
Is crond running on your system ? what do you get if you run the following command from root (or as root via sudo): Code:
crontab -l |
The command for editing your crontab file is
Code:
crontab -e |
crontab -l
# If you don't want the output of a cron job mailed to you, you have to direct # any output to /dev/null. We'll do this here since these jobs should run # properly on a newly installed system. If a script fails, run-parts will # mail a notice to root. # # Run the hourly, daily, weekly, and monthly cron jobs. # Jobs that need different timing may be entered into the crontab as before, # but most really don't need greater granularity than this. If the exact # times of the hourly, daily, weekly, and monthly cron jobs do not suit your # needs, feel free to adjust them. # # Run hourly cron jobs at 47 minutes after the hour: 47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null # # Run daily cron jobs at 4:40 every day: 40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null # # Run weekly cron jobs at 4:30 on the first day of the week: 30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null # # Run monthly cron jobs at 4:20 on the first day of the month: 20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null ----------------------------------------------------------------------------------- while with crontab-e i am not able to write and nither exit via my ssh do not know but i have a script in my user home folder whcih i need to run every 15 min script name eg cleancache.sh so shall o define below the every day with it absolute path can i have an example finding a little tuff as i am from debain and yet learning |
While "crontab -l" just dumps the user's crontab (I asked you to do it from root because I know Slackware has some default cron jobs for root) "crontab -e" opens up an editor to modify the crontab.
The editor that will be used to edit the crontab may depend on your user environment (EDITOR or VISUAL environment variables). If they are not set at all or if either one is set to vi then vi will be used to edit your crontab. Now if you want to run every 15 minutes a script in a user directory, and supposing the script may be run from the user itself without having to use sudo and that the script is in /home/captainfreeky/cleancache.sh , you might want to add something like this in your user's crontab Code:
*/15 * * * * [ -x /home/captainfreeky/cleancache.sh ] && /home/captainfreeky/cleancache.sh >/dev/null 2>&1 If you don't know how to use whatever editor is being used fro editin yout crontab run something like this: Code:
echo "$(crontab -l) Code:
echo "*/15 * * * * [ -x /home/captainfreeky/cleancache.sh ] && /home/captainfreeky/cleancache.sh >/dev/null 2>&1" | crontab - |
Quote:
|
The third post in this LQ thread provides one solution. Use this command to edit crontab:
Code:
env EDITOR=nano crontab -e The code Code:
>/dev/null 2>&1 |
"crontab -" receives input from stdin and put it in your crontab.
">/dev/null 2>&1" redirects stdout to /dev/null and appends standard error to stdout. So Code:
echo "*/15 * * * * [ -x /home/captainfreeky/cleancache.sh ] && /home/captainfreeky/cleancache.sh >/dev/null 2>&1" | crontab - |
All times are GMT -5. The time now is 01:47 AM. |