0
votes
2answers
34 views

How to kill a process in shell script which is running through cron?

I have a shell script which runs in cronjob. This shell script has to kill a process which is running and start the new process again. When I run the script manually it works perfectly fine, but when ...
1
vote
1answer
24 views

bash script not being run by cron [duplicate]

I have a very simple bash script that runs flawlessly when I do ./removeOldBackup.sh or sh /home/myusername/backup/removeOldBackup.sh but when I add it to crontab like * * * * * sh ...
3
votes
1answer
287 views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
-1
votes
1answer
43 views

Cron spamming because of renice [closed]

I have a bash script that I execute using cron. The script begins like this: #! /bin/bash DIR=/home/pi/bin/run renice 19 -p $$ ionice -c 3 -p $$ : Now, every time cron runs this script it sends ...
1
vote
1answer
131 views

Shell script and crontab to capture file size, name and date in a CSV file and then send via email?

I have a number of zip files in a certain folder. I want to capture file name and the size of the files in a CSV format in day wise and put it in crontab so I can report on a daily basis, and then ...
3
votes
1answer
108 views

Automatically detect when a file has reached a size limit

I would like to send an email when a file reach a certain size limit. The only way I thought of doing this is by doing a cronjob which will check the file size and send the email if the file is ...
1
vote
0answers
56 views

Cron job running but not establishing tunnel

I have a script which establishes a reverse tunnel on an endpoint HostB. It looks like this: cat tun.sh #!/usr/bin/env bash # Test code /usr/bin/ssh -V 1> /home/userA/bin/tun.stdout 2> ...
0
votes
1answer
81 views

Can continually assigning a variable in a shell script cause a memory leak?

I've written a short script to copy Apache's server status to a log: #Save date and time to a variable dt=$(date) #Echo date and time to the log file as it's not included in server-status echo "Time ...
7
votes
7answers
1k views

cron Vs. sleep - which is the better one in terms of efficient cpu/memory utilization?

The Case: I need to run some commands/script at certain intervals of time and for this I have two options - 1. set up a cron-job or, 2. implement a loop with sleep in the script itself. Question: ...
0
votes
2answers
251 views

Cron job is not working [closed]

i have a cron job center code hereonfigured at var/spool/cron/testuser, Am calling "adindex.sh" file from there. Am getting results when am directly put the command directly in prompt(php and sh), ...
3
votes
3answers
474 views

Bash script to delete a file called index.html recursively

I need a bash script (not sure how to write the actual .sh file) which I could set to be run by cron every minute and that would delete files with the name index.html that are in a specific directory ...
2
votes
1answer
677 views

“stdin: is not a tty” mails for running scripts as cron jobs

I have several shell scripts (bash) which are started by cron. Every time a script is executed I get an email saying "stdin: is not a tty". Can someone please tell me how to fix this? All scripts run ...
1
vote
1answer
63 views

Does cron impose some limitations to types of commands and privilege of execution? [duplicate]

I've experienced an issue where some of my scripts run perfectly fine when I call them manually, but these same scripts when called as cron jobs via cron don't seem to work at all. So my question: ...
3
votes
4answers
208 views

Does cron jobs per se represent a significant burden on a modern system?

I'd like to run a pretty simple script (is there a dir with name x in dir y if so move it to dir z–and x will only be there about once a day) every 15 seconds or so (one minute divided into 4*15 ...
2
votes
1answer
137 views

Cronjob output to log

I'm using a script for testing broadband speed and I would like to set up a cronjob for testing every n minutes and output to a file. The command to launch it from a shell console and append to ...
4
votes
2answers
424 views

Cron to not run on specific day but all other days

I have a cron setup to execute a bash script daily at 10pm. I have another cron setup to run monthly on the 1st of the month. Both crons launch a bash script, and the only different in the bash script ...
1
vote
1answer
109 views

Script to restart the application

I need to write a script for the below scenario in Linux: Run a cron every 5 minutes. grep the application log file to see if we can see the pattern "ORA-". If we see this pattern: stop the ...
1
vote
0answers
26 views

Script executed from cron doesn't display GUI notifications [duplicate]

The script below has the name notifyrssh.sh. 1: File=/home/vaios/Desktop/tempcron/liveusers.txt //OK 2: cd /home/vaios/Desktop/tempcron 3: ps -aux | grep sshd > ...
3
votes
2answers
126 views

Cron job for every minute executing out of order?

I'm setting up some shell scripting to be executed every five minutes, then every minute on our client's system, to poll a log and pull some timing information to be stored and accessed by another ...
1
vote
1answer
184 views

Why do I get different outputs when running my shellscript manually from when I run it with cron? [duplicate]

I have a fairly simple shell script (foo.sh) that looks like this: #!/bin/bash echo -n "$USER,$(date)," `binary -flags | sed -e '1,30d'`; exit 0; This script is supposed to prepare some output ...
3
votes
1answer
267 views

ls gives me different sort orders during a cron job

I have a cron job that, among other things, does a recursive ls of a directory into a file. This gets compared to another file that I've created that, supposedly, contains an identical listing of the ...
2
votes
1answer
251 views

bash script - supervisor program

I have to write a shell-script that have to do the following tasks: -in every 5 seconds it saves:     -how many users are using joe and/or vi;     -if ...
0
votes
2answers
1k views

Xdotool using “DISPLAY=:0” not works in Crontab

I need to run shell script contains Xdotool codes in /home/z/Desktop/tempo/run.sh. I've tried many ways of DISPLAY=:0 but always not works. I've tried each of below codes, and not works: * * * * * ...
0
votes
1answer
183 views

top not working

My below cronjob is not working. What am I doing wrong here?? */5 * * * * /usr/bin/top -n1 | head -10 >>/tmp/load.txt
2
votes
1answer
1k views

Users home path in a bash script

I'm writing a bash-script that will be run as a cron job everyday. Very basic, I was wanting to change the wallpaper daily. I have mint-14 with mate. The thing I'm getting caught up on right now ...
-1
votes
3answers
1k views

How to run a shell script with export command in crontab

I have a shell script that exports values of variables when executed. The same values will be used in another script. How to run this script(test.sh) in cron. #!/bin/sh export I="10" echo $I I will ...
3
votes
2answers
2k views

Bash script doesn't work as cronjob

I'm trying to get this simple bash script to work within a cronjob. It's used to generate static nginx webserver statistic pages using GoAccess. I tried everything I know to resolve this issue, it ...
8
votes
1answer
946 views

Suppress output unless non-zero exit code

What's the best way to suppress output (stdout and stderr) unless the program exits with a non-zero code? I'm thinking: quiet_success() { file=/tmp/suppressed if ! ( "$@" > "$file" ...
1
vote
1answer
1k views

Trying to create a cron to Rsync then tar the folder

I'm stuck at the first hurdle! I want to run a couple of commands from a bash script. First something like this to rsync some directories: rsync -e ssh -az user-whatever@website.com:/home ...
3
votes
4answers
647 views

command for counting number of active cron jobs in crontabs

Problem statement I have 5 solaris boxes, some have Solaris 10 and some have Solaris 9. All of them have many cronjobs in their crontabs. I would like to know number of active cronjobs available, so ...
5
votes
1answer
1k views

Running cron script with lynx fails to work

I'm trying to automate a login process that can only be done through a browser. I am using the lynx browser to script the actions required to do this. Lynx does this by dumping a user's keystrokes ...
2
votes
4answers
594 views

Is there any handy command line tool to manage Cron jobs?

Would someone suggest any handy command line (NOT web) tool or script which adds, enables and disables Cron jobs? I am looking, for example, for the following (or similar) behavior: sh manageCron.sh ...
1
vote
2answers
1k views

Using rsync in a cronjob when a password is needed

Basically I have a bash script that fetches data from my server to perform a backup. As it is now I have to start that script manually, enter the password, and then wait for it to finish. I would ...
27
votes
10answers
13k views

Correct locking in shell scripts?

Sometimes you have to make sure that only one instance of a shell script is running at the same time. For example a cron job which is executed via crond that does not provide locking on its own (e.g. ...
9
votes
2answers
1k views

How can I delete all files in a folder that haven't been accessed in a certain amount of time?

I'd like to run a nightly cron job that deletes all the files in a folder that haven't been accessed in a week or more. What is the most efficient way to do this in bash?
3
votes
2answers
2k views

Add a one-off scheduled task through a shell script?

I'd like to execute a task at a given time, once. I know I can just use crontab -e to add it there, but I'd like to do that through a shellscript. crontab -e gives me some temporary file to edit ...