All Questions
21 questions
0
votes
2
answers
307
views
source doesn't recognize cwd?
I have a bash script that sources a file, which sources another:
script.sh:
cd /script/dir
source funcs.sh
funcs.sh:
...
source mode.sh
Now this script runs OK when I run it from command line, from ...
1
vote
1
answer
56
views
Process name as the called executable, not the calling script
Edit: I relalised after posting the below that the machine where this 'worked' had in fact not been restarted and the running processes had been launched using an older scheme of actual aliases (...
2
votes
1
answer
283
views
Using HOME variable in crontab result in broken jobs
I have this crontab file with a lot (100+) of jobs that execute some commands in the same directory, suppose ~/Documents/. Instead of cd ~/Documents/ && <command> for every jobs, I can ...
7
votes
2
answers
6k
views
How to run a crontab job only if a file exists?
Is it possible to check for a file existence in a crontab oneliner, and only execute a script if that file existed?
Pseudocode:
* * * * * <if /tmp/signal.txt exists> run /opt/myscript.sh
0
votes
1
answer
939
views
How to do math in If-Statement
I have a Bash script which should only execute in a specific time window (from midnight to 00:15 AM). But if I execute the function, I get [: too many arguments as an error message. How do I solve it? ...
2
votes
1
answer
1k
views
Crontab notify after successful execution?
I have a cron job that executes an R script hourly.
The script checks an online data source that gets updated at an unknown time each day.
If the data source is not updated, the script exits with an ...
3
votes
4
answers
2k
views
How to redirect only stdout in crontab?
I want to only redirect stdout to a logfile from crontab, and let crontab notify me by mail on errors.
If I'd want to redirect both std and err stream, I'd go for 2>&1:
[email protected]
0 23 *...
-1
votes
1
answer
1k
views
sshpass with sftp not working from crontab?
I have a ssh script (for testing purpose) that I can run successfully from cmd:
#!/bin/bash
/usr/bin/sshpass -p 'password' /usr/bin/sftp user@host:/out/test/ <<< $'put -r /data/test/*'
A ./...
2
votes
1
answer
1k
views
BASH_ENV being ignored in AWS Ubuntu 20.04 crontab
With both
SHELL=/bin/bash
BASH_ENV=/home/ubuntu/.bashrc
set on AWS Ubuntu 20.04.1 LTS crontab, .bashrc isn't sourced. I ran into this with the error /bin/bash: python: command not found. python is ...
0
votes
2
answers
669
views
Bash script running perfectly fine on Centos 7 and giving exception on Ubuntu Bionic
Please find below script
if [ "$#" -eq 0 ]; then
dbs=('test_db_1' 'test_db_2')
path='/var/backups/'
else
dbs=( "$@" )
path='/app/mybackups/'
fi
dbuser='test_user_name'
dbpassword='...
1
vote
2
answers
1k
views
CRONTAB, When to set path variable [closed]
I have two bash scripts that both work when I run them.
However when I try to run them in cron, one script(Scipt 2) works and the other(Script 1) does not.
I have narrowed down the problem to ...
0
votes
2
answers
743
views
My script doesn't run according to cron schedule
I have made (with a Stack Exchange help) a script that checks if the web application is available and restarts the web app daemon in order to get it running again (usually helps until I'm at work). It'...
0
votes
1
answer
187
views
How can read file in bash from last read location
I have log file which is updated contunuously.
I want to run cron job every 5 mins which read that file and run awk command to send some metrics to cloudwatch.
Now i want to only read file where i ...
1
vote
1
answer
532
views
Latexmk, from Makefile, from bash script, from Cron - Latexmk not being executed
I have several Git repositories with LaTeX files that I want to have typeset automatically. The idea is to have a central bash script (run by a cronjob) that executes a bash script in every repository,...
-1
votes
1
answer
526
views
error while changing directory using crontab [closed]
This is my script I am trying to rename the files in folder.
rename1.sh
----------
#!/bin/bash
cd /home/lanein1/WestonIN7pm/"$(date +%Y-%m-%d)" && rename s/WestonIN/WestonIN7pm/ *.jpg
cd /...