You are not logged in.
Pages: 1
Hi everyone,
I created a shell script that I run with CRON trough
su
crontab -e
So everything is running almost smoothly.
crontab -e create the job in /var/spool/cron/crontabs/root
So not the best in my case as /var is considered as unimportant and ok to be lost...
So I rather put my cron job in /etc/crontab or etc/cron.d
I've tried to add something quite simple in those file/path (as test) without success
* * * * * root /bin/echo -e "it work" >> /home/Spongebob/Desktop/CronWork.txt 2>/home/Spongebob/Desktop/errors.txt
Any ideas why it's not working ? (errors.txt is not even generated)
Last edited by SpongeBOB (2022-05-29 09:07:38)
Linux noob, plz be kind
Offline
When do you actually want this cron job to repeat?
The five * you have at the beginning are where you should put the date/time info.
minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-7, Sat=6, or mon..sun).
A * is used where that position is not specified. So five * means you haven't set a time/date at all.
As an example here is the mdadm job in my /etc/cron.d/
# cron.d/mdadm -- schedules periodic redundancy checks of MD devices
#
# Copyright © martin f. krafft <madduck@madduck.net>
# distributed under the terms of the Artistic Licence 2.0
#
# By default, run at 00:57 on every Sunday, but do nothing unless the day of
# the month is less than or equal to 7. Thus, only run on the first Sunday of
# each month. crontab(5) sucks, unfortunately, in this regard; therefore this
# hack (see #380425).
# time reset on grendel to 11:57 as more likely to be awake
57 11 * * 0 root if [ -x /usr/share/mdadm/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/share/mdadm/checkarray --cron --all --idle --quiet; fi
Offline
Well, five * like that actually means "run every minute", and generally it looks fine, so it really should work fine provided that
a) the pathnames are fully correct (also in letter casing), and
b) the file does end with at least one newline.
Offline
I stand corrected.
Yes 5 * means 5 wildcards, so it will run whenever cron checks, which is presumably once every minute.
Last edited by Marjorie (2022-05-30 13:55:41)
Offline
...
b) the file does end with at least one newline.
Damn, It was simply that ! and it happen to me with something else... !
Thanks @ralph.ronnquist & Marjorie.
Linux noob, plz be kind
Offline
Pages: 1