Page 2 of 2
Re: NOAA-reports
Posted: Thu 05 May 2016 6:42 am
by rogerthn
cp -v /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago" +%m%d).txt /var/www/NOAA-reports > /tmp/NOAA-reports.log 2>&1
richard_newberry wrote:No nothing is in /tmp/NOAA-reports.log it's like it doesn't execute in cron under user cumulus
but If I do it when I login as cumulus and put the command in without @daily it works but in the /tmp/NOAA-reports.log it's got weird characters in it as shown in the post previous.
Try
as pi and add
Code: Select all
1 2 * * * cp -v /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago" +%m%y).txt /var/www/NOAA-reports > /tmp/NOAA-reports.log 2>&1
This should copy the file at 1 minute past 2 (AM) every day, change 2 to whatever to copy at a different time.
i.e. if cron is running, check with
Re: NOAA-reports
Posted: Fri 06 May 2016 4:47 pm
by richard_newberry
Still didnt execute. Hmmm
Re: NOAA-reports
Posted: Fri 06 May 2016 5:55 pm
by rogerthn
Re: NOAA-reports
Posted: Fri 06 May 2016 10:34 pm
by richard_newberry
cumulus@debian:~$ /etc/init.d/cron status
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled)
Active: active (running) since Wed 2016-05-04 22:22:02 BST; 2 days ago
Docs: man:cron(8)
Main PID: 17634 (cron)
CGroup: /system.slice/cron.service
├─ 1017 ./eggdrop BanditBot.conf
├─ 8998 /usr/bin/atop -a -w /var/log/atop/atop_20160506 600
└─17634 /usr/sbin/cron -f
All it says
I will see if it works under root.
Re: NOAA-reports
Posted: Sat 07 May 2016 6:33 am
by rogerthn
Even if "my" command was
sudo /etc/init.d/cron status
this is
Strange
Do you get an update of /tmp/date.log once every minute with a line as below added with crontab -e?
Code: Select all
* * * * * echo $(date) > /tmp/date.log 2>&1
Re: NOAA-reports
Posted: Sat 07 May 2016 1:49 pm
by richard_newberry
That works date.log is in /tmp every minute.
Re: NOAA-reports
Posted: Sat 07 May 2016 2:03 pm
by richard_newberry
cp -v /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago" +%m%y).txt /var/www/NOAA-reports > /tmp/NOAA-reports.log 2>&1
error message: cp: target ‘+’ is not a directory
Re: NOAA-reports
Posted: Sat 07 May 2016 6:59 pm
by rogerthn
WTH
Can you please show the result from
Code: Select all
echo /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago" +%m%y).txt
AND
Re: NOAA-reports
Posted: Mon 09 May 2016 7:25 am
by richard_newberry
echo /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago" +%m%y).txt
/home/cumulus/CumulusMX/Reports/NOAAMO0516.txt
ls /var/www/NOAA-reports
NOAAMO0116.txt NOAAMO0216.txt NOAAMO0316.txt NOAAMO0416.txt NOAAMO0516.txt NOAAYR2016.txt
crontab -l
10 0 * * * cp -v /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago") +%m%y).txt /var/www/NOAA-reports > /tmp/NOAA-reports.log 2>&1
Re: NOAA-reports
Posted: Mon 09 May 2016 9:07 am
by mcrossley
doesn't the cron entry need to be a shell script so the date substitution works?
Re: NOAA-reports
Posted: Mon 09 May 2016 1:46 pm
by richard_newberry
mcrossley wrote:doesn't the cron entry need to be a shell script so the date substitution works?
What do you suggest the script should be
Re: NOAA-reports
Posted: Mon 09 May 2016 2:11 pm
by freddie
richard_newberry wrote:mcrossley wrote:doesn't the cron entry need to be a shell script so the date substitution works?
What do you suggest the script should be
Code: Select all
#!/bin/sh
cp -v /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago") +%m%y).txt /var/www/NOAA-reports
Re: NOAA-reports
Posted: Mon 09 May 2016 6:26 pm
by rogerthn
richard_newberry wrote:echo /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago" +%m%y).txt
/home/cumulus/CumulusMX/Reports/NOAAMO0516.txt
ls /var/www/NOAA-reports
NOAAMO0116.txt NOAAMO0216.txt NOAAMO0316.txt NOAAMO0416.txt NOAAMO0516.txt NOAAYR2016.txt
crontab -l
10 0 * * * cp -v /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago") +%m%y).txt /var/www/NOAA-reports > /tmp/NOAA-reports.log 2>&1
There seems to be an extra ) in crontab, one after "1 days ago" and one after +%m%y
Try to remove the first?
Re: NOAA-reports
Posted: Mon 09 May 2016 6:55 pm
by rogerthn
The extra ) is not all
Try as below
Code: Select all
10 0 * * * cp -v /home/cumulus/CumulusMX/Reports/NOAAMO$(date --date="1 days ago" +"\%m\%y").txt /var/www/NOAA-reports > /tmp/NOAA-reports.log 2>&1