I have the following bash script lines in a file named test.sh.
Code:
#!/bin/bash
#
# Write Date to cron.log
#
echo "Begin SSI Load $(date +%d%b%y_%T)"
#
# Get the latest rates file for processing.
#
d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1)
filename=$d
export filename
echo "The file name is $filename."
When I execute ./test.sh
Hello.
I know there's at least 4 other threads related to this here.
I'm running a bash script on an ubuntu 12.04 through cron. The script works fine for a few weeks (runs daily backups of websites, mysql databases, and copies to Amazon S3).
However, twice now I've noticed that backups stopped happening. Both times the backup script (backupscript.sh) located in my home folder was no longer there.
Dear all,
i am executing the script.
with help of cron job but it is not executing in cron job.
i check owner and chmod and create the file and execute manually it is working fine but in cron job i set below
Crontab -e
8 14 * * * /home/tplinux/webapp/tpadminhost/collect_ejxml/ejrename.sh
wq!
Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered.
The script is as follow:
#!/bin/sh
for file in file_1.txt file_2.txt file_3.txt
do
awk '{ print "0" }' $file > tmp.tmp
mv tmp.tmp $file
done
And the cron job I am making is:
*/2 * * * * /root/folder/test.sh
Thanks for the help.
I have a remote machine that occasionally changes IP locally and/or public IP to. I have DYNDNS setup as well to help combat this.
However I've written a small script that emails me my IP both local and public IPs setup as a cron job to run every 15 mins. The script works perfectly when run in a terminal window when I'm logged in either at the computer or via SSH.
When I run a script manually using root it is working fine. when I execute the same script inside cron it is not running. I checked the cron is actually calling the script but the script is not executing. I exported the output of echos in the script to the text file but the text file is didn't logged anything.
Is there any variable that cron set when it's running a program ? If the script is running by cron, I'll skip some parts; otherwise invoke those parts.
How can I know if the bash script is started by cron ?
I have a bash script that works with relative paths. It needs to have a working directory that is equal to the directory the script is stored in. This works fine as long as I start it from the prompt, because I can cd to the script's directory first.