Tag Info

Hot answers tagged

6

The commands are being run independently, so it is not the same as expecting them to run in the same shell/environment. You would probably be better served by creating a shell script that performs the desired commands and then calling the script from the crontab. Update: The above was a guess, and/or proposed possibilty (as a comment so tersely and ...


3

As per this Unix&Linux SE answer, you can replace ; with && as different versions of cron across different Linux distributions handle this type of functionality in different ways: cd /home/joe/dev && echo `pwd` | logger


3

The following should work: 58 12 * * * (cd /home/joe/dev; echo `pwd` | logger) By wrapping the commands in parentheses, you should force them all to run in the same subshell.


3

You could also define a function yourself, and include it in your .bash_profile or similar: function with { echo -n "$1> " while read input do if [[ $input == "exit" ]] then break fi eval "$1 $input" echo -n "$1> " done echo } Example usage: user@host $ with git git> status ...


2

The ampersand character (&) actually means something in Linux (well, in a Bourne-compatible shell). It means: run the command as a background task. Because of that, you are actually telling cron to run /usr/bin/wget -O /dev/null http://domain.nl/wp-cron.php?import_key=XXXXXXXXXX in the background, and then to do action=processing. And that's what cron ...


2

In addition to the ampersand that was already mentioned, you also have to be careful with a % character in a cron entry. % in a cron entry will be interpreted as a line break and has to be escaped with a backslash(\%). Make sure the import_key that you censored doesn't have such a character. Also, URLs often have % in them to escape certain characters like ...


1

The .ssh folder probably doesn't/didn't exist when you first ran the command. The safest thing to do is to add a command before the cat that checks/creates the folder: #!/bin/bash mkdir -p /root/.ssh chmod 700 /root/.ssh cat > /root/.ssh/github.id_rsa << EOF <some content> EOF chmod 600 /root/.ssh/github.id_rsa


1

Piping the result to true ensures that the command will always succeed. I have tried this on Linux but not on any Mac OS: cp ./src/*/*.h ./aaa | true


1

You could write a bash or other shell script to do this. An easy alternative that's almost as good would be just to define short aliases and prepend them, for example alias d=docker alias g=gcloud and so on. Then run d ps d ps -a and so on, which is hardly more work than typing just the commands.



Only top voted, non community-wiki answers of a minimum length are eligible