Running a Cronjob for retsore....

Status
Not open for further replies.

Andyd358

Member
Aug 23, 2018
243
8
18
55
UK
Hi

I have added the follwing line to Crontab but unsure if it working (Does not see to be) I take it I may have the syntax wrong

# m h dom mon dow command
0 3 * * * /root/restore.sh | mail -s "PBX Restore Complete" technical@xxxxxxxxx.co.uk

I dont get an email and it does not look like the restore job has ran.

Restore.sh is in the /root/ folder i.e i can run in manulaly by /root/restore.sh

Any pointers please?

Cheers
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,414
376
83
Check what it says in /var/log/syslog.

Many implementations of cron do not spawn a shell to run the command, a shell is what would parse the pipe sign and run the command as two processes.

Why not include the mail command within restore.sh?
 
  • Like
Reactions: Andyd358

ad5ou

Active Member
Jun 12, 2018
884
197
43
I hate junk email so I simply log what scripts are doing on that machine or sometimes copy the logs to a repository. This way I can actively look for what/when a script ran but it doesn't clog up my mailbox if I am not concerned with the status.

I use the following to timestamp a given status log for scripts:
echo $(date -u) "conversions complete" >> /root/convert.log

The above is for a call recording conversion script. I add a start and completed line to convert.log each time the script runs so not only do I know it ran a particular time and day, I can easily determine how long the script took to complete.

Sat 17 Apr 2021 07:00:01 AM UTC conversions started
Sat 17 Apr 2021 07:40:08 AM UTC conversions complete
Sun 18 Apr 2021 07:00:01 AM UTC conversions started
Sun 18 Apr 2021 07:10:16 AM UTC conversions complete
Mon 19 Apr 2021 07:00:01 AM UTC conversions started
Mon 19 Apr 2021 07:04:22 AM UTC conversions complete
Tue 20 Apr 2021 07:00:01 AM UTC conversions started
Tue 20 Apr 2021 07:49:49 AM UTC conversions complete
Wed 21 Apr 2021 07:00:01 AM UTC conversions started
Wed 21 Apr 2021 07:45:47 AM UTC conversions complete
 
Status
Not open for further replies.