Cron.txt file trouble

software development

#1

Could someone help me with my cron.txt file.

I cannot seem to get the crontab to read more than one line in the file.

I have uploaded, I believe successfully the cron.txt file. By looking at crontab -l it shows the file there.

However I only managed to get one line or process to run on it. I can’t seem to get it right for more than one line.

I have tried two lines directly under each other such as this

*****/etc
*****/etc

Plus I have tried a line between them such as this

*****/etc

*****/etc

Neither of these work

An instuction that I saw somewhere was to hit ‘enter’ after the last letter of the script. e.g blahblah.php ‘enter’

However the crontab does not like this, through experimentation of getting my one line command to work,
and therefore I have not done this.

I have searched google to try and find instructions about multiple lines of command but everything I find only has one line.

I am very new to crontab and command line stuff. It has taken me about 4 days to get to this point. I’m mostly a gui type user.

Can’t get any help out of the ‘support’ for some reason they won’t help with this stuff.

Thankyou

Craig


#2

I’ve had the exact same problem. What I did was to create another text file with the extension.sh and then use crontab to point to that file with all the commands in it.
For example

crontab.txt
0 1 * * */3 bash /home/user_name/backup/backup.sh

/home/user_name/backup/backup.sh
#!/bin/bash
suffix=$(date +%y
%m_%d)
mysqldump --opt -uDB_USER -pDB_PASS -h DB_HOST DB_TABLE > /home/user_name/backup/$suffix-site_backup.sql
mysqldump --opt -uDB_USER2 -pDB_PASS2 -h DB_HOST2 DB_TABLE2 > /home/user_name/backup/$suffix-site_backup2.sql

Not particularly nice way to do it, but it seems to work. I’d much rather have a proper crontab though, where I can put these lines into one file =/


#3

This could be related to a problem I’ve been having lately where FTP uploads to Dreamhost seem to go in binary mode even when I tell the FTP program to use ASCII mode, which means that files I edit under Windows have the wrong line breaks for Dreamhost’s Linux server. This may cause scripts, config files, etc., to fail after the first line because they hit an unknown carriage-return character.

– Dan


#4

Thanks for the reply. However due to my lack of command line knowledge it means nothing to me. Understand the write a .sh file, but you lose me after that. Can see you have something about mysql in there but don’t know why you are referencing it.


#5

thank for the reply. I played around with this but it didn’t seem to help. However it is a good thing to watch out for.